Use $TMUX_PANE if it is defined

Also closes #1637 in most cases
This commit is contained in:
Foo 2016-08-17 22:27:37 +03:00
parent d135631e67
commit 70246c38e7
6 changed files with 48 additions and 7 deletions

View File

@ -10,8 +10,13 @@ _powerline_columns_fallback() {
return 0 return 0
} }
_powerline_tmux_pane() {
echo "${TMUX_PANE:-`TMUX="$_POWERLINE_TMUX" tmux display -p "#D"`}" | \
tr -d ' %'
}
_powerline_tmux_setenv() { _powerline_tmux_setenv() {
TMUX="$_POWERLINE_TMUX" tmux setenv -g TMUX_"$1"_`tmux display -p "#D" | tr -d %` "$2" TMUX="$_POWERLINE_TMUX" tmux setenv -g TMUX_"$1"_`_powerline_tmux_pane` "$2"
TMUX="$_POWERLINE_TMUX" tmux refresh -S TMUX="$_POWERLINE_TMUX" tmux refresh -S
} }

View File

@ -82,9 +82,17 @@ function powerline-setup
if env $POWERLINE_CONFIG_COMMAND shell --shell=fish uses tmux if env $POWERLINE_CONFIG_COMMAND shell --shell=fish uses tmux
if test -n "$TMUX" if test -n "$TMUX"
if tmux refresh -S ^/dev/null if tmux refresh -S ^/dev/null
set -g _POWERLINE_TMUX "$TMUX"
function _powerline_tmux_pane
if test -z "$TMUX_PANE"
env TMUX="$_POWERLINE_TMUX" tmux display -p "#D" | tr -d ' %'
else
echo "$TMUX_PANE" | tr -d ' %'
end
end
function _powerline_tmux_setenv function _powerline_tmux_setenv
tmux setenv -g TMUX_$argv[1]_(tmux display -p "#D" | tr -d "%") "$argv[2]" env TMUX="$_POWERLINE_TMUX" tmux setenv -g TMUX_$argv[1]_(_powerline_tmux_pane) "$argv[2]"
tmux refresh -S env TMUX="$_POWERLINE_TMUX" tmux refresh -S
end end
function --on-variable PWD _powerline_tmux_set_pwd function --on-variable PWD _powerline_tmux_set_pwd
_powerline_tmux_setenv PWD "$PWD" _powerline_tmux_setenv PWD "$PWD"

View File

@ -36,6 +36,14 @@ fn _powerline_common_setup {
_POWERLINE_SAVED_PWD = '' _POWERLINE_SAVED_PWD = ''
} }
fn _powerline_tmux_pane {
if (test x$TMUX_PANE '!=' x) {
echo $TMUX_PANE | tr -d ' %'
} else {
TMUX=$_POWERLINE_TMUX tmux display -p '#D' | tr -d ' %'
}
}
fn _powerline_tmux_setenv { fn _powerline_tmux_setenv {
} }
@ -73,7 +81,7 @@ if (test x$POWERLINE_CONFIG_COMMAND '!=' x) {
fn _powerline_tmux_setenv { fn _powerline_tmux_setenv {
if (test x$2 '!=' x) { if (test x$2 '!=' x) {
TMUX=$_POWERLINE_TMUX tmux setenv -g TMUX_$1^_`{ TMUX=$_POWERLINE_TMUX tmux setenv -g TMUX_$1^_`{
TMUX=$_POWERLINE_TMUX tmux display -p '#D' | tr -d % _powerline_tmux_pane
} $2 } $2
} }
} }

View File

@ -104,8 +104,13 @@ _powerline_set_command() {
fi fi
} }
_powerline_tmux_pane() {
echo "${TMUX_PANE:-`TMUX="$_POWERLINE_TMUX" tmux display -p "#D"`}" | \
tr -d ' %'
}
_powerline_tmux_setenv() { _powerline_tmux_setenv() {
TMUX="$_POWERLINE_TMUX" tmux setenv -g TMUX_"$1"_`tmux display -p "#D" | tr -d %` "$2" TMUX="$_POWERLINE_TMUX" tmux setenv -g TMUX_"$1"_`_powerline_tmux_pane` "$2"
TMUX="$_POWERLINE_TMUX" tmux refresh -S TMUX="$_POWERLINE_TMUX" tmux refresh -S
} }

View File

@ -21,7 +21,17 @@ else
endif endif
endif endif
if ( { $POWERLINE_CONFIG_COMMAND shell --shell=tcsh uses tmux } ) then if ( { $POWERLINE_CONFIG_COMMAND shell --shell=tcsh uses tmux } ) then
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' if ( $?TMUX_PANE ) then
if ( "$TMUX_PANE" == "" ) then
set _POWERLINE_TMUX_PANE="`tmux display -p '#D'`"
else
set _POWERLINE_TMUX_PANE="$TMUX_PANE"
endif
else
set _POWERLINE_TMUX_PANE="`tmux display -p '#D'`"
endif
set _POWERLINE_TMUX_PANE="`echo $_POWERLINE_TMUX_PANE:q | tr -d '% '`"
alias _powerline_tmux_set_pwd 'if ( $?TMUX && { tmux refresh -S >&/dev/null } ) tmux setenv -g TMUX_PWD_$_POWERLINE_TMUX_PANE $PWD:q ; if ( $?TMUX ) tmux refresh -S >&/dev/null'
alias cwdcmd "`alias cwdcmd` ; _powerline_tmux_set_pwd" alias cwdcmd "`alias cwdcmd` ; _powerline_tmux_set_pwd"
endif endif
if ( { $POWERLINE_CONFIG_COMMAND shell --shell=tcsh uses prompt } ) then if ( { $POWERLINE_CONFIG_COMMAND shell --shell=tcsh uses prompt } ) then

View File

@ -20,6 +20,11 @@ _powerline_append_precmd_function() {
integer _POWERLINE_JOBNUM integer _POWERLINE_JOBNUM
_powerline_tmux_pane() {
local -x TMUX="$_POWERLINE_TMUX"
echo "${TMUX_PANE:-`tmux display -p "#D"`}" | tr -d ' %'
}
_powerline_init_tmux_support() { _powerline_init_tmux_support() {
emulate -L zsh emulate -L zsh
if test -n "$TMUX" && tmux refresh -S &>/dev/null ; then if test -n "$TMUX" && tmux refresh -S &>/dev/null ; then
@ -29,7 +34,7 @@ _powerline_init_tmux_support() {
function -g _powerline_tmux_setenv() { function -g _powerline_tmux_setenv() {
emulate -L zsh emulate -L zsh
local -x TMUX="$_POWERLINE_TMUX" local -x TMUX="$_POWERLINE_TMUX"
tmux setenv -g TMUX_"$1"_$(tmux display -p "#D" | tr -d %) "$2" tmux setenv -g TMUX_"$1"_$(_powerline_tmux_pane) "$2"
tmux refresh -S tmux refresh -S
} }