[oe-commits] [openembedded-core] 12/12: terminal: Fix working directory in tmux terminals

git at git.openembedded.org git at git.openembedded.org
Mon Feb 4 11:19:25 UTC 2019

This is an automated email from the git hooks/post-receive script.

rpurdie pushed a commit to branch master-next
in repository openembedded-core.

commit cb751b24e324abdbdeaa08e6230381523c751608
Author: Jacob Kroon <jacob.kroon at gmail.com>
AuthorDate: Sun Feb 3 01:31:27 2019 +0100

    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.
    Signed-off-by: Jacob Kroon <jacob.kroon at gmail.com>
    Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
 meta/lib/oe/terminal.py | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/meta/lib/oe/terminal.py b/meta/lib/oe/terminal.py
index afbda59..e404555 100644
--- a/meta/lib/oe/terminal.py
+++ b/meta/lib/oe/terminal.py
@@ -39,7 +39,7 @@ class Terminal(Popen, metaclass=Registry):
     def format_command(self, sh_cmd, title):
-        fmt = {'title': title or 'Terminal', 'command': sh_cmd}
+        fmt = {'title': title or 'Terminal', 'command': sh_cmd, 'cwd': os.getcwd() }
         if isinstance(self.command, str):
             return shlex.split(self.command.format(**fmt))
@@ -117,7 +117,7 @@ class Screen(Terminal):
 class TmuxRunning(Terminal):
     """Open a new pane in the current running tmux window"""
     name = 'tmux-running'
-    command = 'tmux split-window "{command}"'
+    command = 'tmux split-window -c "{cwd}" "{command}"'
     priority = 2.75
     def __init__(self, sh_cmd, title=None, env=None, d=None):
@@ -135,7 +135,7 @@ class TmuxRunning(Terminal):
 class TmuxNewWindow(Terminal):
     """Open a new window in the current running tmux session"""
     name = 'tmux-new-window'
-    command = 'tmux new-window -n "{title}" "{command}"'
+    command = 'tmux new-window -c "{cwd}" -n "{title}" "{command}"'
     priority = 2.70
     def __init__(self, sh_cmd, title=None, env=None, d=None):
@@ -149,7 +149,7 @@ class TmuxNewWindow(Terminal):
 class Tmux(Terminal):
     """Start a new tmux session and window"""
-    command = 'tmux new -d -s devshell -n devshell "{command}"'
+    command = 'tmux new -c "{cwd}" -d -s devshell -n devshell "{command}"'
     priority = 0.75
     def __init__(self, sh_cmd, title=None, env=None, d=None):
@@ -160,7 +160,7 @@ class Tmux(Terminal):
         # devshells, if it's already there, add a new window to it.
         window_name = 'devshell-%i' % os.getpid()
-        self.command = 'tmux new -d -s {0} -n {0} "{{command}}"'.format(window_name)
+        self.command = 'tmux new -c "{{cwd}}" -d -s {0} -n {0} "{{command}}"'.format(window_name)
         Terminal.__init__(self, sh_cmd, title, env, d)
         attach_cmd = 'tmux att -t {0}'.format(window_name)

To stop receiving notification emails like this one, please contact
the administrator of this repository.

More information about the Openembedded-commits mailing list