From 45cc73aa8dd21f1f82b0536e9693b793e7953114 Mon Sep 17 00:00:00 2001 From: ZyX Date: Fri, 28 Mar 2014 08:56:04 +0400 Subject: [PATCH] =?UTF-8?q?Use=20=E2=80=9Ctmux=20refresh=20-S=E2=80=9D=20t?= =?UTF-8?q?o=20check=20for=20tmux=20presence?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reason: tmux may be launched and $TMUX set, but current shell still not under tmux (and most likely there are no active session). In this case `tmux refresh -S` may fail with “no clients” message, which is annoying. --- powerline/bindings/bash/powerline.sh | 2 +- powerline/bindings/fish/powerline-setup.fish | 2 +- powerline/bindings/tcsh/powerline.tcsh | 2 +- powerline/bindings/zsh/powerline.zsh | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/powerline/bindings/bash/powerline.sh b/powerline/bindings/bash/powerline.sh index 4aeefea6..6f1de23b 100644 --- a/powerline/bindings/bash/powerline.sh +++ b/powerline/bindings/bash/powerline.sh @@ -10,7 +10,7 @@ if test -z "${POWERLINE_COMMAND}" ; then fi _powerline_init_tmux_support() { - if test -n "$TMUX" && tmux source-file /dev/null &>/dev/null ; then + if test -n "$TMUX" && tmux refresh -S &>/dev/null ; then # TMUX variable may be unset to create new tmux session inside this one _POWERLINE_TMUX="$TMUX" diff --git a/powerline/bindings/fish/powerline-setup.fish b/powerline/bindings/fish/powerline-setup.fish index 71acb3cb..d925a6fc 100644 --- a/powerline/bindings/fish/powerline-setup.fish +++ b/powerline/bindings/fish/powerline-setup.fish @@ -21,7 +21,7 @@ function powerline-setup end _powerline_update if test -n "$TMUX" - if tmux source-file /dev/null ^/dev/null + if tmux refresh -S ^/dev/null function _powerline_tmux_setenv tmux setenv -g TMUX_$argv[1]_(tmux display -p "#D" | tr -d "%") "$argv[2]" tmux refresh -S diff --git a/powerline/bindings/tcsh/powerline.tcsh b/powerline/bindings/tcsh/powerline.tcsh index b83498ad..68e031e8 100644 --- a/powerline/bindings/tcsh/powerline.tcsh +++ b/powerline/bindings/tcsh/powerline.tcsh @@ -14,7 +14,7 @@ if ! $?POWERLINE_COMMAND then setenv POWERLINE_COMMAND $POWERLINE_SOURCED:h:h:h:h:q/scripts/powerline endif endif -alias _powerline_tmux_set_pwd 'if ( $?TMUX && { tmux source-file /dev/null >&/dev/null } ) tmux setenv -g TMUX_PWD_`tmux display -p "#D" | tr -d %` $PWD:q ; if ( $?TMUX && { tmux source-file /dev/null >&/dev/null } ) tmux refresh -S' +alias _powerline_tmux_set_pwd 'if ( $?TMUX && { tmux refresh -S >&/dev/null } ) tmux setenv -g TMUX_PWD_`tmux display -p "#D" | tr -d %` $PWD:q ; if ( $?TMUX ) tmux refresh -S >&/dev/null' alias _powerline_set_prompt 'set prompt="`$POWERLINE_COMMAND shell left -r tcsh_prompt --last_exit_code=$?`"' alias _powerline_set_rprompt 'set rprompt="`$POWERLINE_COMMAND shell right -r tcsh_prompt --last_exit_code=$?` "' alias cwdcmd "`alias cwdcmd` ; _powerline_tmux_set_pwd" diff --git a/powerline/bindings/zsh/powerline.zsh b/powerline/bindings/zsh/powerline.zsh index 46123940..838a99a7 100644 --- a/powerline/bindings/zsh/powerline.zsh +++ b/powerline/bindings/zsh/powerline.zsh @@ -12,7 +12,7 @@ integer _POWERLINE_JOBNUM _powerline_init_tmux_support() { emulate -L zsh - if test -n "$TMUX" && tmux source-file /dev/null &>/dev/null ; then + if test -n "$TMUX" && tmux refresh -S &>/dev/null ; then # TMUX variable may be unset to create new tmux session inside this one typeset -g _POWERLINE_TMUX="$TMUX"