From ca4234b1c36ace85e82d98ff895885eda76b346d Mon Sep 17 00:00:00 2001 From: 2Shirt <2xShirt@gmail.com> Date: Thu, 6 Dec 2018 15:29:06 -0700 Subject: [PATCH] Added working_dir arg for tmux command sections --- .bin/Scripts/functions/hw_diags.py | 3 ++- .bin/Scripts/functions/tmux.py | 9 +++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.bin/Scripts/functions/hw_diags.py b/.bin/Scripts/functions/hw_diags.py index a2aca6c8..3c1fc5b3 100644 --- a/.bin/Scripts/functions/hw_diags.py +++ b/.bin/Scripts/functions/hw_diags.py @@ -654,7 +654,8 @@ def run_mprime_test(state): run_program(['apple-fans', 'max']) tmux_update_pane( state.panes['mprime'], - command=['hw-diags-prime95', global_vars['TmpDir']]) + command=['hw-diags-prime95', global_vars['TmpDir']], + working_dir=global_vars['TmpDir']) time_limit = int(MPRIME_LIMIT) * 60 try: for i in range(time_limit): diff --git a/.bin/Scripts/functions/tmux.py b/.bin/Scripts/functions/tmux.py index c9a92194..84ab96cc 100644 --- a/.bin/Scripts/functions/tmux.py +++ b/.bin/Scripts/functions/tmux.py @@ -32,7 +32,8 @@ def tmux_split_window( lines=None, percent=None, behind=False, vertical=False, follow=False, target_pane=None, - command=None, text=None, watch=None): + working_dir=None, command=None, + text=None, watch=None): """Run tmux split-window command and return pane_id as str.""" # Bail early if not lines and not percent: @@ -57,6 +58,8 @@ def tmux_split_window( if target_pane: cmd.extend(['-t', str(target_pane)]) + if working_dir: + cmd.extend(['-c', working_dir]) if command: cmd.extend(command) elif text: @@ -71,13 +74,15 @@ def tmux_split_window( result = run_program(cmd) return result.stdout.decode().strip() -def tmux_update_pane(pane_id, command=None, text=None): +def tmux_update_pane(pane_id, command=None, text=None, working_dir=None): """Respawn with either a new command or new text.""" # Bail early if not command and not text: raise Exception('Neither command nor text specified.') cmd = ['tmux', 'respawn-pane', '-k', '-t', pane_id] + if working_dir: + cmd.extend(['-c', working_dir]) if command: cmd.extend(command) elif text: