Added watch option to use tail instead of cat
* tail -f acurately prints backspace (^H) characters * badblocks output uses them and wouldn't work with watch/cat
This commit is contained in:
parent
dc8416b5f7
commit
e96ac5c156
1 changed files with 17 additions and 12 deletions
|
|
@ -46,7 +46,7 @@ def tmux_split_window(
|
||||||
behind=False, vertical=False,
|
behind=False, vertical=False,
|
||||||
follow=False, target_pane=None,
|
follow=False, target_pane=None,
|
||||||
working_dir=None, command=None,
|
working_dir=None, command=None,
|
||||||
text=None, watch=None):
|
text=None, watch=None, watch_cmd='cat'):
|
||||||
"""Run tmux split-window command and return pane_id as str."""
|
"""Run tmux split-window command and return pane_id as str."""
|
||||||
# Bail early
|
# Bail early
|
||||||
if not lines and not percent:
|
if not lines and not percent:
|
||||||
|
|
@ -79,19 +79,21 @@ def tmux_split_window(
|
||||||
cmd.extend(['echo-and-hold "{}"'.format(text)])
|
cmd.extend(['echo-and-hold "{}"'.format(text)])
|
||||||
elif watch:
|
elif watch:
|
||||||
create_file(watch)
|
create_file(watch)
|
||||||
cmd.extend([
|
if watch_cmd == 'cat':
|
||||||
'watch', '--color', '--no-title',
|
cmd.extend([
|
||||||
'--interval', '1',
|
'watch', '--color', '--no-title',
|
||||||
'cat', watch])
|
'--interval', '1',
|
||||||
|
'cat', watch])
|
||||||
|
elif watch_cmd == 'tail':
|
||||||
|
cmd.extend(['tail', '-f', watch])
|
||||||
|
|
||||||
# Run and return pane_id
|
# Run and return pane_id
|
||||||
result = run_program(cmd)
|
result = run_program(cmd)
|
||||||
return result.stdout.decode().strip()
|
return result.stdout.decode().strip()
|
||||||
|
|
||||||
def tmux_update_pane(
|
def tmux_update_pane(
|
||||||
pane_id, command=None,
|
pane_id, command=None, working_dir=None,
|
||||||
text=None, watch=None,
|
text=None, watch=None, watch_cmd='cat'):
|
||||||
working_dir=None):
|
|
||||||
"""Respawn with either a new command or new text."""
|
"""Respawn with either a new command or new text."""
|
||||||
# Bail early
|
# Bail early
|
||||||
if not command and not text and not watch:
|
if not command and not text and not watch:
|
||||||
|
|
@ -106,10 +108,13 @@ def tmux_update_pane(
|
||||||
cmd.extend(['echo-and-hold "{}"'.format(text)])
|
cmd.extend(['echo-and-hold "{}"'.format(text)])
|
||||||
elif watch:
|
elif watch:
|
||||||
create_file(watch)
|
create_file(watch)
|
||||||
cmd.extend([
|
if watch_cmd == 'cat':
|
||||||
'watch', '--color', '--no-title',
|
cmd.extend([
|
||||||
'--interval', '1',
|
'watch', '--color', '--no-title',
|
||||||
'cat', watch])
|
'--interval', '1',
|
||||||
|
'cat', watch])
|
||||||
|
elif watch_cmd == 'tail':
|
||||||
|
cmd.extend(['tail', '-f', watch])
|
||||||
|
|
||||||
run_program(cmd)
|
run_program(cmd)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue