Also use the same code for tmux

This commit is contained in:
ZyX 2014-08-02 20:16:38 +04:00
parent 05384e31e4
commit 8374a66ca7
2 changed files with 24 additions and 12 deletions

View File

@ -111,6 +111,10 @@ def source_tmux_files(pl, args):
version = get_tmux_version(pl) version = get_tmux_version(pl)
for fname, priority in sorted(get_tmux_configs(version), key=(lambda v: v[1])): for fname, priority in sorted(get_tmux_configs(version), key=(lambda v: v[1])):
run_tmux_command('source', fname) run_tmux_command('source', fname)
cmd = deduce_command()
if cmd:
run_tmux_command('set-environment', '-g', 'POWERLINE_COMMAND', deduce_command())
run_tmux_command('refresh-client')
def create_powerline_logger(args): def create_powerline_logger(args):
@ -124,11 +128,10 @@ def create_powerline_logger(args):
def check_command(cmd): def check_command(cmd):
if which(cmd): if which(cmd):
print(cmd) return cmd
sys.exit(0)
def shell_command(pl, args): def deduce_command():
'''Deduce which command to use for ``powerline`` '''Deduce which command to use for ``powerline``
Candidates: Candidates:
@ -144,11 +147,21 @@ def shell_command(pl, args):
* ``powerline-render``. Should not really ever be used. * ``powerline-render``. Should not really ever be used.
* ``{powerline_root}/scripts/powerline-render``. Same. * ``{powerline_root}/scripts/powerline-render``. Same.
''' '''
check_command('powerline') return (
check_command(os.path.join(POWERLINE_ROOT, 'scripts', 'powerline')) None
if which('sh') and which('sed') and which('socat'): or check_command('powerline')
check_command(os.path.join(POWERLINE_ROOT, 'client', 'powerline.sh')) or check_command(os.path.join(POWERLINE_ROOT, 'scripts', 'powerline'))
check_command(os.path.join(POWERLINE_ROOT, 'client', 'powerline.py')) or ((which('sh') and which('sed') and which('socat'))
check_command('powerline-render') and check_command(os.path.join(POWERLINE_ROOT, 'client', 'powerline.sh')))
check_command(os.path.join(POWERLINE_ROOT, 'scripts', 'powerline-render')) or check_command(os.path.join(POWERLINE_ROOT, 'client', 'powerline.py'))
sys.exit(1) or check_command('powerline-render')
or check_command(os.path.join(POWERLINE_ROOT, 'scripts', 'powerline-render'))
)
def shell_command(pl, args):
cmd = deduce_command()
if cmd:
print(cmd)
else:
sys.exit(1)

View File

@ -1,4 +1,3 @@
if-shell 'test -z "$POWERLINE_COMMAND"' 'if-shell "which powerline" "set-environment -g POWERLINE_COMMAND powerline" "set-environment -g POWERLINE_COMMAND powerline-render"'
if-shell 'test -z "$POWERLINE_CONFIG_COMMAND"' 'set-environment -g POWERLINE_CONFIG_COMMAND powerline-config' if-shell 'test -z "$POWERLINE_CONFIG_COMMAND"' 'set-environment -g POWERLINE_CONFIG_COMMAND powerline-config'
# Don't version-check for this core functionality -- anything too old to # Don't version-check for this core functionality -- anything too old to