mirror of
https://github.com/powerline/powerline.git
synced 2025-07-24 06:15:41 +02:00
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
|
into different directory or replacing ``powerline`` script with
|
||||||
``powerline-client`` for performance reasons.
|
``powerline-client`` for performance reasons.
|
||||||
|
|
||||||
Note: ``$POWERLINE_COMMAND`` appears in shell scripts without quotes thus you
|
.. note::
|
||||||
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
|
``$POWERLINE_COMMAND`` appears in shell scripts without quotes thus you can
|
||||||
is passed to ``eval`` and depends on the shell used. POSIX-compatible shells,
|
specify additional parameters in bash. In zsh you will have to make
|
||||||
zsh, bash and fish will split this variable in this case.
|
``$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() {
|
_powerline_init_tmux_support() {
|
||||||
if test -n "$TMUX" && tmux refresh -S &>/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
|
# TMUX variable may be unset to create new tmux session inside this one
|
||||||
@ -46,7 +35,24 @@ _powerline_prompt() {
|
|||||||
return $last_exit_code
|
return $last_exit_code
|
||||||
}
|
}
|
||||||
|
|
||||||
test "x$PROMPT_COMMAND" != "x${PROMPT_COMMAND%_powerline_prompt*}" ||
|
_powerline_setup_prompt() {
|
||||||
export PROMPT_COMMAND=$'_powerline_prompt\n'"${PROMPT_COMMAND}"
|
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
|
function powerline-setup
|
||||||
if test -z "$POWERLINE_COMMAND"
|
if test -z "$POWERLINE_NO_FISH_PROMPT$POWERLINE_NO_SHELL_PROMPT"
|
||||||
if which powerline-client >/dev/null
|
if test -z "$POWERLINE_COMMAND"
|
||||||
set -g -x POWERLINE_COMMAND powerline-client
|
if which powerline-client >/dev/null
|
||||||
else if which powerline >/dev/null
|
set -g -x POWERLINE_COMMAND powerline-client
|
||||||
set -g -x POWERLINE_COMMAND powerline
|
else if which powerline >/dev/null
|
||||||
else
|
set -g -x POWERLINE_COMMAND powerline
|
||||||
set -g -x POWERLINE_COMMAND (dirname (status -f))/../../../scripts/powerline
|
else
|
||||||
|
set -g -x POWERLINE_COMMAND (dirname (status -f))/../../../scripts/powerline
|
||||||
|
end
|
||||||
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
|
end
|
||||||
function --on-variable POWERLINE_COMMAND _powerline_update
|
if test -z "$POWERLINE_NO_FISH_TMUX_SUPPORT$POWERLINE_NO_SHELL_TMUX_SUPPORT"
|
||||||
set -l addargs "--last_exit_code=\$status --last_pipe_status=\$status --jobnum=(jobs -p | wc -l)"
|
if test -n "$TMUX"
|
||||||
eval "
|
if tmux refresh -S ^/dev/null
|
||||||
function fish_prompt
|
function _powerline_tmux_setenv
|
||||||
$POWERLINE_COMMAND shell left $addargs
|
tmux setenv -g TMUX_$argv[1]_(tmux display -p "#D" | tr -d "%") "$argv[2]"
|
||||||
end
|
tmux refresh -S
|
||||||
function fish_right_prompt
|
end
|
||||||
$POWERLINE_COMMAND shell right $addargs
|
function --on-variable PWD _powerline_tmux_set_pwd
|
||||||
end
|
_powerline_tmux_setenv PWD "$PWD"
|
||||||
"
|
end
|
||||||
end
|
function --on-signal WINCH _powerline_tmux_set_columns
|
||||||
_powerline_update
|
_powerline_tmux_setenv COLUMNS "$COLUMNS"
|
||||||
if test -n "$TMUX"
|
end
|
||||||
if tmux refresh -S ^/dev/null
|
_powerline_tmux_set_columns
|
||||||
function _powerline_tmux_setenv
|
_powerline_tmux_set_pwd
|
||||||
tmux setenv -g TMUX_$argv[1]_(tmux display -p "#D" | tr -d "%") "$argv[2]"
|
|
||||||
tmux refresh -S
|
|
||||||
end
|
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
|
end
|
||||||
end
|
end
|
||||||
|
@ -14,8 +14,12 @@ if ! $?POWERLINE_COMMAND then
|
|||||||
setenv POWERLINE_COMMAND $POWERLINE_SOURCED:h:h:h:h:q/scripts/powerline
|
setenv POWERLINE_COMMAND $POWERLINE_SOURCED:h:h:h:h:q/scripts/powerline
|
||||||
endif
|
endif
|
||||||
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'
|
if ! ( $?POWERLINE_NO_TCSH_TMUX_SUPPORT || $?POWERLINE_NO_SHELL_TMUX_SUPPORT ) then
|
||||||
alias _powerline_set_prompt 'set prompt="`$POWERLINE_COMMAND shell left -r tcsh_prompt --last_exit_code=$?`"'
|
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_rprompt 'set rprompt="`$POWERLINE_COMMAND shell right -r tcsh_prompt --last_exit_code=$?` "'
|
alias cwdcmd "`alias cwdcmd` ; _powerline_tmux_set_pwd"
|
||||||
alias cwdcmd "`alias cwdcmd` ; _powerline_tmux_set_pwd"
|
endif
|
||||||
alias precmd "`alias precmd` ; _powerline_set_prompt ; _powerline_set_rprompt"
|
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 promptpercent
|
||||||
setopt promptsubst
|
setopt promptsubst
|
||||||
_powerline_setup_prompt
|
if test -z "$POWERLINE_NO_ZSH_PROMPT$POWERLINE_NO_SHELL_PROMPT" ; then
|
||||||
_powerline_init_tmux_support
|
_powerline_setup_prompt
|
||||||
_powerline_init_modes_support
|
_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…
x
Reference in New Issue
Block a user