diff options
author | Jacob Kroon <jacob.kroon@gmail.com> | 2019-02-03 01:31:27 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2019-02-05 13:53:47 +0000 |
commit | 404f7cec87bc9fabe48a5dbff38690faf96094b3 (patch) | |
tree | 4b2f9541df0ecca3ac01e24eae0414cc9ca4333f | |
parent | 93f86e2c4728fe9402842867fe124e89718b7f4b (diff) | |
download | poky-404f7cec87bc9fabe48a5dbff38690faf96094b3.tar.gz |
terminal: Fix working directory in tmux terminals
Recent version of tmux seems to use PWD from the environment instead of the
actual working directory. Help it use the correct path.
Fixes setting the correct working directory when running
devshell and menuconfig tasks.
(From OE-Core rev: 938a089b52e7bf5f67406f55234ab2d22236e9b6)
Signed-off-by: Jacob Kroon <jacob.kroon@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | meta/lib/oe/terminal.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/meta/lib/oe/terminal.py b/meta/lib/oe/terminal.py index afbda595db..e4045559fc 100644 --- a/meta/lib/oe/terminal.py +++ b/meta/lib/oe/terminal.py | |||
@@ -39,7 +39,7 @@ class Terminal(Popen, metaclass=Registry): | |||
39 | raise | 39 | raise |
40 | 40 | ||
41 | def format_command(self, sh_cmd, title): | 41 | def format_command(self, sh_cmd, title): |
42 | fmt = {'title': title or 'Terminal', 'command': sh_cmd} | 42 | fmt = {'title': title or 'Terminal', 'command': sh_cmd, 'cwd': os.getcwd() } |
43 | if isinstance(self.command, str): | 43 | if isinstance(self.command, str): |
44 | return shlex.split(self.command.format(**fmt)) | 44 | return shlex.split(self.command.format(**fmt)) |
45 | else: | 45 | else: |
@@ -117,7 +117,7 @@ class Screen(Terminal): | |||
117 | class TmuxRunning(Terminal): | 117 | class TmuxRunning(Terminal): |
118 | """Open a new pane in the current running tmux window""" | 118 | """Open a new pane in the current running tmux window""" |
119 | name = 'tmux-running' | 119 | name = 'tmux-running' |
120 | command = 'tmux split-window "{command}"' | 120 | command = 'tmux split-window -c "{cwd}" "{command}"' |
121 | priority = 2.75 | 121 | priority = 2.75 |
122 | 122 | ||
123 | def __init__(self, sh_cmd, title=None, env=None, d=None): | 123 | def __init__(self, sh_cmd, title=None, env=None, d=None): |
@@ -135,7 +135,7 @@ class TmuxRunning(Terminal): | |||
135 | class TmuxNewWindow(Terminal): | 135 | class TmuxNewWindow(Terminal): |
136 | """Open a new window in the current running tmux session""" | 136 | """Open a new window in the current running tmux session""" |
137 | name = 'tmux-new-window' | 137 | name = 'tmux-new-window' |
138 | command = 'tmux new-window -n "{title}" "{command}"' | 138 | command = 'tmux new-window -c "{cwd}" -n "{title}" "{command}"' |
139 | priority = 2.70 | 139 | priority = 2.70 |
140 | 140 | ||
141 | def __init__(self, sh_cmd, title=None, env=None, d=None): | 141 | def __init__(self, sh_cmd, title=None, env=None, d=None): |
@@ -149,7 +149,7 @@ class TmuxNewWindow(Terminal): | |||
149 | 149 | ||
150 | class Tmux(Terminal): | 150 | class Tmux(Terminal): |
151 | """Start a new tmux session and window""" | 151 | """Start a new tmux session and window""" |
152 | command = 'tmux new -d -s devshell -n devshell "{command}"' | 152 | command = 'tmux new -c "{cwd}" -d -s devshell -n devshell "{command}"' |
153 | priority = 0.75 | 153 | priority = 0.75 |
154 | 154 | ||
155 | def __init__(self, sh_cmd, title=None, env=None, d=None): | 155 | def __init__(self, sh_cmd, title=None, env=None, d=None): |
@@ -160,7 +160,7 @@ class Tmux(Terminal): | |||
160 | # devshells, if it's already there, add a new window to it. | 160 | # devshells, if it's already there, add a new window to it. |
161 | window_name = 'devshell-%i' % os.getpid() | 161 | window_name = 'devshell-%i' % os.getpid() |
162 | 162 | ||
163 | self.command = 'tmux new -d -s {0} -n {0} "{{command}}"'.format(window_name) | 163 | self.command = 'tmux new -c "{{cwd}}" -d -s {0} -n {0} "{{command}}"'.format(window_name) |
164 | Terminal.__init__(self, sh_cmd, title, env, d) | 164 | Terminal.__init__(self, sh_cmd, title, env, d) |
165 | 165 | ||
166 | attach_cmd = 'tmux att -t {0}'.format(window_name) | 166 | attach_cmd = 'tmux att -t {0}'.format(window_name) |