Make POWERLINE_COMMAND a single path without arguments

Ref #1201
This commit is contained in:
ZyX 2015-01-07 15:07:27 +03:00
parent 10300756cc
commit c3e6c2aeab
9 changed files with 27 additions and 23 deletions

View File

@ -215,12 +215,11 @@ putting powerline into different directory.
.. note:: .. note::
``$POWERLINE_COMMAND`` appears in shell scripts without quotes thus you can ``$POWERLINE_COMMAND`` is always treated as one path in shell bindings, so
specify additional parameters in bash. In tmux it is passed to ``eval`` and you may use paths with spaces in it. To specify additional arguments one may
depends on the shell used. POSIX-compatible shells, zsh, bash and fish will use ``$POWERLINE_COMMAND_ARGS``, but note that this variable exists for
split this variable in this case. Do not use this feature for overriding testing purposes only and may be removed. One should use :ref:`Environment
configuration: there are :ref:`Environment variables overrides variable overrides <local-configuration-overrides-env>` instead.
<local-configuration-overrides-env>`.
If you want to disable prompt in shell, but still have tmux support or if you 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 want to disable tmux support you can use variables

View File

@ -41,7 +41,7 @@ _powerline_init_tmux_support() {
_powerline_local_prompt() { _powerline_local_prompt() {
# Arguments: side, renderer_module arg, last_exit_code, jobnum, local theme # Arguments: side, renderer_module arg, last_exit_code, jobnum, local theme
$POWERLINE_COMMAND shell $1 \ "$POWERLINE_COMMAND" $POWERLINE_COMMAND_ARGS shell $1 \
$2 \ $2 \
--last-exit-code=$3 \ --last-exit-code=$3 \
--jobnum=$4 \ --jobnum=$4 \
@ -51,7 +51,7 @@ _powerline_local_prompt() {
_powerline_prompt() { _powerline_prompt() {
# Arguments: side, last_exit_code, jobnum # Arguments: side, last_exit_code, jobnum
$POWERLINE_COMMAND shell $1 \ "$POWERLINE_COMMAND" $POWERLINE_COMMAND_ARGS shell $1 \
--width="${COLUMNS:-$(_powerline_columns_fallback)}" \ --width="${COLUMNS:-$(_powerline_columns_fallback)}" \
-r.bash \ -r.bash \
--last-exit-code=$2 \ --last-exit-code=$2 \

View File

@ -65,10 +65,10 @@ function powerline-setup
end end
eval " eval "
function fish_prompt function fish_prompt
$POWERLINE_COMMAND shell $promptside $addargs env \$POWERLINE_COMMAND $POWERLINE_COMMAND_ARGS shell $promptside $addargs
end end
function fish_right_prompt function fish_right_prompt
$POWERLINE_COMMAND shell right $addargs env \$POWERLINE_COMMAND $POWERLINE_COMMAND_ARGS shell right $addargs
$rpromptpast $rpromptpast
end end
function --on-signal WINCH _powerline_set_columns function --on-signal WINCH _powerline_set_columns

View File

@ -136,7 +136,7 @@ _powerline_set_jobs() {
_powerline_local_prompt() { _powerline_local_prompt() {
# Arguments: side, exit_code, local theme # Arguments: side, exit_code, local theme
_powerline_set_jobs _powerline_set_jobs
$POWERLINE_COMMAND shell $1 \ "$POWERLINE_COMMAND" $POWERLINE_COMMAND_ARGS shell $1 \
$_POWERLINE_RENDERER_ARG \ $_POWERLINE_RENDERER_ARG \
--renderer-arg="client_id=$$" \ --renderer-arg="client_id=$$" \
--last-exit-code=$2 \ --last-exit-code=$2 \
@ -147,7 +147,7 @@ _powerline_local_prompt() {
_powerline_prompt() { _powerline_prompt() {
# Arguments: side, exit_code # Arguments: side, exit_code
_powerline_set_jobs _powerline_set_jobs
$POWERLINE_COMMAND shell $1 \ "$POWERLINE_COMMAND" $POWERLINE_COMMAND_ARGS shell $1 \
--width="${COLUMNS:-$(_powerline_columns_fallback)}" \ --width="${COLUMNS:-$(_powerline_columns_fallback)}" \
$_POWERLINE_RENDERER_ARG \ $_POWERLINE_RENDERER_ARG \
--renderer-arg="client_id=$$" \ --renderer-arg="client_id=$$" \

View File

@ -32,15 +32,18 @@ if ( { $POWERLINE_CONFIG_COMMAND shell --shell=tcsh uses prompt } ) then
set POWERLINE_COMMAND="`$POWERLINE_CONFIG_COMMAND:q shell command`" set POWERLINE_COMMAND="`$POWERLINE_CONFIG_COMMAND:q shell command`"
endif endif
endif endif
if ! $?POWERLINE_COMMAND_ARGS then
set POWERLINE_COMMAND_ARGS=""
endif
if ( $?POWERLINE_NO_TCSH_ABOVE || $?POWERLINE_NO_SHELL_ABOVE ) then if ( $?POWERLINE_NO_TCSH_ABOVE || $?POWERLINE_NO_SHELL_ABOVE ) then
alias _powerline_above true alias _powerline_above true
else else
alias _powerline_above '$POWERLINE_COMMAND shell above --renderer-arg=client_id=$$ --last-exit-code=$POWERLINE_STATUS --width=$POWERLINE_COLUMNS' alias _powerline_above '$POWERLINE_COMMAND:q $POWERLINE_COMMAND_ARGS shell above --renderer-arg=client_id=$$ --last-exit-code=$POWERLINE_STATUS --width=$POWERLINE_COLUMNS'
endif endif
alias _powerline_set_prompt 'set prompt="`$POWERLINE_COMMAND shell left -r .tcsh --renderer-arg=client_id=$$ --last-exit-code=$POWERLINE_STATUS --width=$POWERLINE_COLUMNS`"' alias _powerline_set_prompt 'set prompt="`$POWERLINE_COMMAND:q $POWERLINE_COMMAND_ARGS shell left -r .tcsh --renderer-arg=client_id=$$ --last-exit-code=$POWERLINE_STATUS --width=$POWERLINE_COLUMNS`"'
alias _powerline_set_rprompt 'set rprompt="`$POWERLINE_COMMAND shell right -r .tcsh --renderer-arg=client_id=$$ --last-exit-code=$POWERLINE_STATUS --width=$POWERLINE_COLUMNS` "' alias _powerline_set_rprompt 'set rprompt="`$POWERLINE_COMMAND:q $POWERLINE_COMMAND_ARGS shell right -r .tcsh --renderer-arg=client_id=$$ --last-exit-code=$POWERLINE_STATUS --width=$POWERLINE_COLUMNS` "'
alias _powerline_set_columns 'set POWERLINE_COLUMNS=`stty size|cut -d" " -f2` ; set POWERLINE_COLUMNS=`expr $POWERLINE_COLUMNS - 2`' alias _powerline_set_columns 'set POWERLINE_COLUMNS=`stty size|cut -d" " -f2` ; set POWERLINE_COLUMNS=`expr $POWERLINE_COLUMNS - 2`'
alias precmd 'set POWERLINE_STATUS=$? ; '"`alias precmd`"' ; _powerline_set_columns ; _powerline_above ; _powerline_set_prompt ; _powerline_set_rprompt' alias precmd 'set POWERLINE_STATUS=$? ; '"`alias precmd`"' ; _powerline_set_columns ; _powerline_above ; _powerline_set_prompt ; _powerline_set_rprompt'

View File

@ -2,7 +2,7 @@ set -g status on
set -g status-utf8 on set -g status-utf8 on
set -g status-interval 2 set -g status-interval 2
set -g status-left-length 20 set -g status-left-length 20
set -g status-right '#(eval $POWERLINE_COMMAND tmux right -R pane_id=`tmux display -p "#D"`)' set -g status-right '#(env "$POWERLINE_COMMAND" $POWERLINE_COMMAND_ARGS tmux right -R pane_id=`tmux display -p "#D"`)'
set -g status-right-length 150 set -g status-right-length 150
set -g window-status-format "#[$_POWERLINE_WINDOW_COLOR]$_POWERLINE_LEFT_HARD_DIVIDER_SPACES#I #[$_POWERLINE_WINDOW_DIVIDER_COLOR]$_POWERLINE_LEFT_SOFT_DIVIDER#[default]#W $_POWERLINE_LEFT_HARD_DIVIDER_SPACES" set -g window-status-format "#[$_POWERLINE_WINDOW_COLOR]$_POWERLINE_LEFT_HARD_DIVIDER_SPACES#I #[$_POWERLINE_WINDOW_DIVIDER_COLOR]$_POWERLINE_LEFT_SOFT_DIVIDER#[default]#W $_POWERLINE_LEFT_HARD_DIVIDER_SPACES"
set -g window-status-current-format "#[$_POWERLINE_WINDOW_CURRENT_HARD_DIVIDER_COLOR]$_POWERLINE_LEFT_HARD_DIVIDER#[$_POWERLINE_WINDOW_CURRENT_COLOR]#I $_POWERLINE_LEFT_SOFT_DIVIDER#[$_POWERLINE_WINDOW_NAME_COLOR]#W #[$_POWERLINE_WINDOW_CURRENT_HARD_DIVIDER_NEXT_COLOR]$_POWERLINE_LEFT_HARD_DIVIDER" set -g window-status-current-format "#[$_POWERLINE_WINDOW_CURRENT_HARD_DIVIDER_COLOR]$_POWERLINE_LEFT_HARD_DIVIDER#[$_POWERLINE_WINDOW_CURRENT_COLOR]#I $_POWERLINE_LEFT_SOFT_DIVIDER#[$_POWERLINE_WINDOW_NAME_COLOR]#W #[$_POWERLINE_WINDOW_CURRENT_HARD_DIVIDER_NEXT_COLOR]$_POWERLINE_LEFT_HARD_DIVIDER"

View File

@ -1,5 +1,5 @@
# powerline_tmux_1.8_plus.conf # powerline_tmux_1.8_plus.conf
# tmux Version 1.8 introduces the 'client_prefix' format variable, applicable # tmux Version 1.8 introduces the 'client_prefix' format variable, applicable
# for versions 1.8+ # for versions 1.8+
set -qg status-left "#{?client_prefix,#[fg=$_POWERLINE_SESSION_PREFIX_FG]#[bg=$_POWERLINE_SESSION_PREFIX_BG]#[$_POWERLINE_SESSION_PREFIX_ATTR],#[fg=$_POWERLINE_SESSION_FG]#[bg=$_POWERLINE_SESSION_BG]#[$_POWERLINE_SESSION_ATTR]} #S #{?client_prefix,#[fg=$_POWERLINE_SESSION_PREFIX_BG],#[fg=$_POWERLINE_SESSION_BG]}#[bg=$_POWERLINE_BACKGROUND_BG]#[nobold]$_POWERLINE_LEFT_HARD_DIVIDER#(eval \$POWERLINE_COMMAND tmux left)" set -qg status-left "#{?client_prefix,#[fg=$_POWERLINE_SESSION_PREFIX_FG]#[bg=$_POWERLINE_SESSION_PREFIX_BG]#[$_POWERLINE_SESSION_PREFIX_ATTR],#[fg=$_POWERLINE_SESSION_FG]#[bg=$_POWERLINE_SESSION_BG]#[$_POWERLINE_SESSION_ATTR]} #S #{?client_prefix,#[fg=$_POWERLINE_SESSION_PREFIX_BG],#[fg=$_POWERLINE_SESSION_BG]}#[bg=$_POWERLINE_BACKGROUND_BG]#[nobold]$_POWERLINE_LEFT_HARD_DIVIDER#(env \$POWERLINE_COMMAND \$POWERLINE_COMMAND_ARGS tmux left)"
# vim: ft=tmux # vim: ft=tmux

View File

@ -151,11 +151,11 @@ _powerline_setup_prompt() {
local add_args_2=$add_args$new_args_2 local add_args_2=$add_args$new_args_2
add_args+=' --width=$(( ${COLUMNS:-$(_powerline_columns_fallback)} - ${ZLE_RPROMPT_INDENT:-1} ))' add_args+=' --width=$(( ${COLUMNS:-$(_powerline_columns_fallback)} - ${ZLE_RPROMPT_INDENT:-1} ))'
local add_args_r2=$add_args$new_args_2 local add_args_r2=$add_args$new_args_2
PS1='$($=POWERLINE_COMMAND shell aboveleft '$add_args')' PS1='$("$POWERLINE_COMMAND" $=POWERLINE_COMMAND_ARGS shell aboveleft '$add_args')'
RPS1='$($=POWERLINE_COMMAND shell right '$add_args')' RPS1='$("$POWERLINE_COMMAND" $=POWERLINE_COMMAND_ARGS shell right '$add_args')'
PS2='$($=POWERLINE_COMMAND shell left '$add_args_2')' PS2='$("$POWERLINE_COMMAND" $=POWERLINE_COMMAND_ARGS shell left '$add_args_2')'
RPS2='$($=POWERLINE_COMMAND shell right '$add_args_r2')' RPS2='$("$POWERLINE_COMMAND" $=POWERLINE_COMMAND_ARGS shell right '$add_args_r2')'
PS3='$($=POWERLINE_COMMAND shell left '$add_args_3')' PS3='$("$POWERLINE_COMMAND" $=POWERLINE_COMMAND_ARGS shell left '$add_args_3')'
fi fi
} }

View File

@ -79,6 +79,7 @@ run() {
POWERLINE_SHELL_CONTINUATION=$additional_prompts \ POWERLINE_SHELL_CONTINUATION=$additional_prompts \
POWERLINE_SHELL_SELECT=$additional_prompts \ POWERLINE_SHELL_SELECT=$additional_prompts \
POWERLINE_CONFIG_PATHS="$PWD/powerline/config_files" \ POWERLINE_CONFIG_PATHS="$PWD/powerline/config_files" \
POWERLINE_COMMAND_ARGS="${POWERLINE_COMMAND_ARGS}" \
POWERLINE_COMMAND="${POWERLINE_COMMAND}" \ POWERLINE_COMMAND="${POWERLINE_COMMAND}" \
"$@" "$@"
} }
@ -303,7 +304,8 @@ if test -z "${ONLY_SHELL}" || test "x${ONLY_SHELL%sh}" != "x${ONLY_SHELL}" || te
if test "x$ONLY_TEST_CLIENT" != "x" && test "x$TEST_CLIENT" != "x$ONLY_TEST_CLIENT" ; then if test "x$ONLY_TEST_CLIENT" != "x" && test "x$TEST_CLIENT" != "x$ONLY_TEST_CLIENT" ; then
continue continue
fi fi
POWERLINE_COMMAND="$POWERLINE_COMMAND --socket $ADDRESS" POWERLINE_COMMAND_ARGS="--socket $ADDRESS"
POWERLINE_COMMAND="$POWERLINE_COMMAND"
export POWERLINE_COMMAND export POWERLINE_COMMAND
echo ">> powerline command is ${POWERLINE_COMMAND:-empty}" echo ">> powerline command is ${POWERLINE_COMMAND:-empty}"
J=-1 J=-1