parent
c9d1b81954
commit
a90b080328
|
@ -33,12 +33,9 @@ function powerline-setup
|
||||||
if test -z "$POWERLINE_COMMAND"
|
if test -z "$POWERLINE_COMMAND"
|
||||||
set -g POWERLINE_COMMAND (env $POWERLINE_CONFIG_COMMAND shell command)
|
set -g POWERLINE_COMMAND (env $POWERLINE_CONFIG_COMMAND shell command)
|
||||||
end
|
end
|
||||||
function --on-variable fish_bind_mode _powerline_bind_mode
|
|
||||||
set -g -x _POWERLINE_MODE $fish_bind_mode
|
|
||||||
end
|
|
||||||
function --on-variable fish_key_bindings _powerline_set_default_mode
|
function --on-variable fish_key_bindings _powerline_set_default_mode
|
||||||
if test x$fish_key_bindings != xfish_vi_key_bindings
|
if test x$fish_key_bindings != xfish_vi_key_bindings
|
||||||
set -g -x _POWERLINE_DEFAULT_MODE default
|
set -g _POWERLINE_DEFAULT_MODE default
|
||||||
else
|
else
|
||||||
set -g -e _POWERLINE_DEFAULT_MODE
|
set -g -e _POWERLINE_DEFAULT_MODE
|
||||||
end
|
end
|
||||||
|
@ -51,6 +48,8 @@ function powerline-setup
|
||||||
# the same value in two shells
|
# the same value in two shells
|
||||||
set -l addargs "$addargs --renderer-arg=client_id="(random)
|
set -l addargs "$addargs --renderer-arg=client_id="(random)
|
||||||
set -l addargs "$addargs --width=\$_POWERLINE_COLUMNS"
|
set -l addargs "$addargs --width=\$_POWERLINE_COLUMNS"
|
||||||
|
set -l addargs "$addargs --renderer-arg=mode=\$fish_bind_mode"
|
||||||
|
set -l addargs "$addargs --renderer-arg=default_mode=\$_POWERLINE_DEFAULT_MODE"
|
||||||
set -l promptside
|
set -l promptside
|
||||||
set -l rpromptpast
|
set -l rpromptpast
|
||||||
set -l columnsexpr
|
set -l columnsexpr
|
||||||
|
|
|
@ -60,7 +60,7 @@ _powerline_init_modes_support() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function -g _powerline_set_true_keymap_name() {
|
function -g _powerline_set_true_keymap_name() {
|
||||||
export _POWERLINE_MODE="${1}"
|
_POWERLINE_MODE="${1}"
|
||||||
local plm_bk="$(bindkey -lL ${_POWERLINE_MODE})"
|
local plm_bk="$(bindkey -lL ${_POWERLINE_MODE})"
|
||||||
if [[ $plm_bk = 'bindkey -A'* ]] ; then
|
if [[ $plm_bk = 'bindkey -A'* ]] ; then
|
||||||
_powerline_set_true_keymap_name ${(Q)${${(z)plm_bk}[3]}}
|
_powerline_set_true_keymap_name ${(Q)${${(z)plm_bk}[3]}}
|
||||||
|
@ -83,7 +83,7 @@ _powerline_init_modes_support() {
|
||||||
_powerline_set_main_keymap_name
|
_powerline_set_main_keymap_name
|
||||||
|
|
||||||
if [[ "$_POWERLINE_MODE" != vi* ]] ; then
|
if [[ "$_POWERLINE_MODE" != vi* ]] ; then
|
||||||
export _POWERLINE_DEFAULT_MODE="$_POWERLINE_MODE"
|
_POWERLINE_DEFAULT_MODE="$_POWERLINE_MODE"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
precmd_functions+=( _powerline_set_main_keymap_name )
|
precmd_functions+=( _powerline_set_main_keymap_name )
|
||||||
|
@ -145,6 +145,8 @@ _powerline_setup_prompt() {
|
||||||
add_args+=' --renderer-arg="client_id=$$"'
|
add_args+=' --renderer-arg="client_id=$$"'
|
||||||
add_args+=' --renderer-arg="shortened_path=${(%):-%~}"'
|
add_args+=' --renderer-arg="shortened_path=${(%):-%~}"'
|
||||||
add_args+=' --jobnum=$_POWERLINE_JOBNUM'
|
add_args+=' --jobnum=$_POWERLINE_JOBNUM'
|
||||||
|
add_args+=' --renderer-arg="mode=$_POWERLINE_MODE"'
|
||||||
|
add_args+=' --renderer-arg="default_mode=$_POWERLINE_DEFAULT_MODE"'
|
||||||
local new_args_2=' --renderer-arg="parser_state=${(%%):-%_}"'
|
local new_args_2=' --renderer-arg="parser_state=${(%%):-%_}"'
|
||||||
new_args_2+=' --renderer-arg="local_theme=continuation"'
|
new_args_2+=' --renderer-arg="local_theme=continuation"'
|
||||||
local add_args_3=$add_args' --renderer-arg="local_theme=select"'
|
local add_args_3=$add_args' --renderer-arg="local_theme=select"'
|
||||||
|
@ -179,15 +181,15 @@ _powerline_add_widget() {
|
||||||
eval "function $save_widget() { emulate -L zsh; $widget \$@ }"
|
eval "function $save_widget() { emulate -L zsh; $widget \$@ }"
|
||||||
eval "${old_widget_command/$widget/$save_widget}"
|
eval "${old_widget_command/$widget/$save_widget}"
|
||||||
zle -N $widget $function
|
zle -N $widget $function
|
||||||
export _POWERLINE_SAVE_WIDGET="$save_widget"
|
_POWERLINE_SAVE_WIDGET="$save_widget"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
if test -z "${POWERLINE_CONFIG_COMMAND}" ; then
|
if test -z "${POWERLINE_CONFIG_COMMAND}" ; then
|
||||||
if which powerline-config >/dev/null ; then
|
if which powerline-config >/dev/null ; then
|
||||||
export POWERLINE_CONFIG_COMMAND=powerline-config
|
POWERLINE_CONFIG_COMMAND=powerline-config
|
||||||
else
|
else
|
||||||
export POWERLINE_CONFIG_COMMAND="$_POWERLINE_SOURCED:h:h:h:h/scripts/powerline-config"
|
POWERLINE_CONFIG_COMMAND="$_POWERLINE_SOURCED:h:h:h:h/scripts/powerline-config"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -82,7 +82,7 @@ def write_output(args, powerline, segment_info, write, encoding):
|
||||||
for line in powerline.render_above_lines(
|
for line in powerline.render_above_lines(
|
||||||
width=args.width,
|
width=args.width,
|
||||||
segment_info=segment_info,
|
segment_info=segment_info,
|
||||||
mode=segment_info['environ'].get('_POWERLINE_MODE'),
|
mode=segment_info.get('mode', None),
|
||||||
):
|
):
|
||||||
write(line.encode(encoding, 'replace'))
|
write(line.encode(encoding, 'replace'))
|
||||||
write(b'\n')
|
write(b'\n')
|
||||||
|
@ -93,6 +93,6 @@ def write_output(args, powerline, segment_info, write, encoding):
|
||||||
width=args.width,
|
width=args.width,
|
||||||
side=args.side,
|
side=args.side,
|
||||||
segment_info=segment_info,
|
segment_info=segment_info,
|
||||||
mode=segment_info['environ'].get('_POWERLINE_MODE'),
|
mode=segment_info.get('mode', None),
|
||||||
)
|
)
|
||||||
write(rendered.encode(encoding, 'replace'))
|
write(rendered.encode(encoding, 'replace'))
|
||||||
|
|
|
@ -65,11 +65,11 @@ def mode(pl, segment_info, override={'vicmd': 'COMMND', 'viins': 'INSERT'}, defa
|
||||||
``$POWERLINE_DEFAULT_MODE`` variable. This variable is set by zsh
|
``$POWERLINE_DEFAULT_MODE`` variable. This variable is set by zsh
|
||||||
bindings for any mode that does not start from ``vi``.
|
bindings for any mode that does not start from ``vi``.
|
||||||
'''
|
'''
|
||||||
mode = segment_info['mode']
|
mode = segment_info.get('mode', None)
|
||||||
if not mode:
|
if not mode:
|
||||||
pl.debug('No or empty _POWERLINE_MODE variable')
|
pl.debug('No mode specified')
|
||||||
return None
|
return None
|
||||||
default = default or segment_info['environ'].get('_POWERLINE_DEFAULT_MODE')
|
default = default or segment_info.get('default_mode', None)
|
||||||
if mode == default:
|
if mode == default:
|
||||||
return None
|
return None
|
||||||
try:
|
try:
|
||||||
|
@ -78,9 +78,9 @@ def mode(pl, segment_info, override={'vicmd': 'COMMND', 'viins': 'INSERT'}, defa
|
||||||
# Note: with zsh line editor you can emulate as much modes as you wish.
|
# Note: with zsh line editor you can emulate as much modes as you wish.
|
||||||
# Thus having unknown mode is not an error: maybe just some developer
|
# Thus having unknown mode is not an error: maybe just some developer
|
||||||
# added support for his own zle widgets. As there is no built-in mode()
|
# added support for his own zle widgets. As there is no built-in mode()
|
||||||
# function like in VimL and _POWERLINE_MODE is likely be defined by our
|
# function like in VimL and mode is likely be defined by our code or by
|
||||||
# code or by somebody knowing what he is doing there is absolutely no
|
# somebody knowing what he is doing there is absolutely no need in
|
||||||
# need in keeping translations dictionary.
|
# keeping translations dictionary.
|
||||||
return mode.upper()
|
return mode.upper()
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue