Merge branch 'allow-disabling-prompt-support' into develop
This commit is contained in:
commit
a7d92a65f4
|
@ -546,8 +546,28 @@ specific powerline implementation. This is mostly useful for putting powerline
|
|||
into different directory or replacing ``powerline`` script with
|
||||
``powerline-client`` for performance reasons.
|
||||
|
||||
Note: ``$POWERLINE_COMMAND`` appears in shell scripts without quotes thus you
|
||||
can specify additional parameters in bash. In zsh you will have to make
|
||||
``$POWERLINE_COMMAND`` an array parameter to achieve the same result. In tmux it
|
||||
is passed to ``eval`` and depends on the shell used. POSIX-compatible shells,
|
||||
zsh, bash and fish will split this variable in this case.
|
||||
.. note::
|
||||
|
||||
``$POWERLINE_COMMAND`` appears in shell scripts without quotes thus you can
|
||||
specify additional parameters in bash. In zsh you will have to make
|
||||
``$POWERLINE_COMMAND`` an array parameter to achieve the same result. In
|
||||
tmux it is passed to ``eval`` and depends on the shell used.
|
||||
POSIX-compatible shells, zsh, bash and fish will split this variable in this
|
||||
case.
|
||||
|
||||
If you want to disable prompt in shell, but still have tmux support or if you
|
||||
want to disable tmux support you can use variables
|
||||
``$POWERLINE_NO_{SHELL}_PROMPT``/``$POWERLINE_NO_SHELL_PROMPT`` and
|
||||
``$POWERLINE_NO_{SHELL}_TMUX_SUPPORT``/``$POWERLINE_NO_SHELL_TMUX_SUPPORT``
|
||||
(substitute ``{SHELL}`` with the name of the shell (all-caps) you want to
|
||||
disable support for (e.g. ``BASH``) or use all-inclusive ``SHELL`` that will
|
||||
disable support for all shells). These variables have no effect after
|
||||
configuration script was sourced (in fish case: after ``powerline-setup``
|
||||
function was run). To disable specific feature support set one of these
|
||||
variables to some non-empty value.
|
||||
|
||||
.. note::
|
||||
|
||||
Most supported shells’ configuration scripts check for additional
|
||||
configuration variables being empty. But tcsh configuration script checks
|
||||
for variables being *defined*, not empty.
|
||||
|
|
|
@ -1,14 +1,3 @@
|
|||
if test -z "${POWERLINE_COMMAND}" ; then
|
||||
if which powerline-client &>/dev/null ; then
|
||||
export POWERLINE_COMMAND=powerline-client
|
||||
elif which powerline &>/dev/null ; then
|
||||
export POWERLINE_COMMAND=powerline
|
||||
else
|
||||
# `$0` is set to `-bash` when using SSH so that won't work
|
||||
export POWERLINE_COMMAND="$(dirname "$BASH_SOURCE")/../../../scripts/powerline"
|
||||
fi
|
||||
fi
|
||||
|
||||
_powerline_init_tmux_support() {
|
||||
if test -n "$TMUX" && tmux refresh -S &>/dev/null ; then
|
||||
# TMUX variable may be unset to create new tmux session inside this one
|
||||
|
@ -46,7 +35,24 @@ _powerline_prompt() {
|
|||
return $last_exit_code
|
||||
}
|
||||
|
||||
test "x$PROMPT_COMMAND" != "x${PROMPT_COMMAND%_powerline_prompt*}" ||
|
||||
export PROMPT_COMMAND=$'_powerline_prompt\n'"${PROMPT_COMMAND}"
|
||||
_powerline_setup_prompt() {
|
||||
if test -z "${POWERLINE_COMMAND}" ; then
|
||||
if which powerline-client &>/dev/null ; then
|
||||
export POWERLINE_COMMAND=powerline-client
|
||||
elif which powerline &>/dev/null ; then
|
||||
export POWERLINE_COMMAND=powerline
|
||||
else
|
||||
# `$0` is set to `-bash` when using SSH so that won't work
|
||||
export POWERLINE_COMMAND="$(dirname "$BASH_SOURCE")/../../../scripts/powerline"
|
||||
fi
|
||||
fi
|
||||
test "x$PROMPT_COMMAND" != "x${PROMPT_COMMAND%_powerline_prompt*}" ||
|
||||
export PROMPT_COMMAND=$'_powerline_prompt\n'"${PROMPT_COMMAND}"
|
||||
}
|
||||
|
||||
_powerline_init_tmux_support
|
||||
if test -z "$POWERLINE_NO_BASH_PROMPT$POWERLINE_NO_SHELL_PROMPT" ; then
|
||||
_powerline_setup_prompt
|
||||
fi
|
||||
if test -z "$POWERLINE_NO_BASH_TMUX_SUPPORT$POWERLINE_NO_SHELL_TMUX_SUPPORT" ; then
|
||||
_powerline_init_tmux_support
|
||||
fi
|
||||
|
|
|
@ -1,39 +1,43 @@
|
|||
function powerline-setup
|
||||
if test -z "$POWERLINE_COMMAND"
|
||||
if which powerline-client >/dev/null
|
||||
set -g -x POWERLINE_COMMAND powerline-client
|
||||
else if which powerline >/dev/null
|
||||
set -g -x POWERLINE_COMMAND powerline
|
||||
else
|
||||
set -g -x POWERLINE_COMMAND (dirname (status -f))/../../../scripts/powerline
|
||||
if test -z "$POWERLINE_NO_FISH_PROMPT$POWERLINE_NO_SHELL_PROMPT"
|
||||
if test -z "$POWERLINE_COMMAND"
|
||||
if which powerline-client >/dev/null
|
||||
set -g -x POWERLINE_COMMAND powerline-client
|
||||
else if which powerline >/dev/null
|
||||
set -g -x POWERLINE_COMMAND powerline
|
||||
else
|
||||
set -g -x POWERLINE_COMMAND (dirname (status -f))/../../../scripts/powerline
|
||||
end
|
||||
end
|
||||
function --on-variable POWERLINE_COMMAND _powerline_update
|
||||
set -l addargs "--last_exit_code=\$status --last_pipe_status=\$status --jobnum=(jobs -p | wc -l)"
|
||||
eval "
|
||||
function fish_prompt
|
||||
$POWERLINE_COMMAND shell left $addargs
|
||||
end
|
||||
function fish_right_prompt
|
||||
$POWERLINE_COMMAND shell right $addargs
|
||||
end
|
||||
"
|
||||
end
|
||||
_powerline_update
|
||||
end
|
||||
function --on-variable POWERLINE_COMMAND _powerline_update
|
||||
set -l addargs "--last_exit_code=\$status --last_pipe_status=\$status --jobnum=(jobs -p | wc -l)"
|
||||
eval "
|
||||
function fish_prompt
|
||||
$POWERLINE_COMMAND shell left $addargs
|
||||
end
|
||||
function fish_right_prompt
|
||||
$POWERLINE_COMMAND shell right $addargs
|
||||
end
|
||||
"
|
||||
end
|
||||
_powerline_update
|
||||
if test -n "$TMUX"
|
||||
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
|
||||
if test -z "$POWERLINE_NO_FISH_TMUX_SUPPORT$POWERLINE_NO_SHELL_TMUX_SUPPORT"
|
||||
if test -n "$TMUX"
|
||||
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
|
||||
end
|
||||
function --on-variable PWD _powerline_tmux_set_pwd
|
||||
_powerline_tmux_setenv PWD "$PWD"
|
||||
end
|
||||
function --on-signal WINCH _powerline_tmux_set_columns
|
||||
_powerline_tmux_setenv COLUMNS "$COLUMNS"
|
||||
end
|
||||
_powerline_tmux_set_columns
|
||||
_powerline_tmux_set_pwd
|
||||
end
|
||||
function --on-variable PWD _powerline_tmux_set_pwd
|
||||
_powerline_tmux_setenv PWD "$PWD"
|
||||
end
|
||||
function --on-signal WINCH _powerline_tmux_set_columns
|
||||
_powerline_tmux_setenv COLUMNS "$COLUMNS"
|
||||
end
|
||||
_powerline_tmux_set_columns
|
||||
_powerline_tmux_set_pwd
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,8 +14,12 @@ 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 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"
|
||||
alias precmd "`alias precmd` ; _powerline_set_prompt ; _powerline_set_rprompt"
|
||||
if ! ( $?POWERLINE_NO_TCSH_TMUX_SUPPORT || $?POWERLINE_NO_SHELL_TMUX_SUPPORT ) 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'
|
||||
alias cwdcmd "`alias cwdcmd` ; _powerline_tmux_set_pwd"
|
||||
endif
|
||||
if ! ( $?POWERLINE_NO_TCSH_PROMPT || $?POWERLINE_NO_SHELL_PROMPT ) then
|
||||
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 precmd "`alias precmd` ; _powerline_set_prompt ; _powerline_set_rprompt"
|
||||
endif
|
||||
|
|
|
@ -150,6 +150,10 @@ _powerline_add_widget() {
|
|||
|
||||
setopt promptpercent
|
||||
setopt promptsubst
|
||||
_powerline_setup_prompt
|
||||
_powerline_init_tmux_support
|
||||
_powerline_init_modes_support
|
||||
if test -z "$POWERLINE_NO_ZSH_PROMPT$POWERLINE_NO_SHELL_PROMPT" ; then
|
||||
_powerline_setup_prompt
|
||||
_powerline_init_modes_support
|
||||
fi
|
||||
if test -z "$POWERLINE_NO_ZSH_TMUX_SUPPORT$POWERLINE_NO_SHELL_TMUX_SUPPORT" ; then
|
||||
_powerline_init_tmux_support
|
||||
fi
|
||||
|
|
Loading…
Reference in New Issue