Omit any non-vi* mode by default

This commit is contained in:
ZyX 2013-11-17 01:36:16 +04:00
parent 34d4877abf
commit 36c007058d
2 changed files with 9 additions and 2 deletions

View File

@ -99,6 +99,10 @@ _powerline_zle_keymap_select() {
_powerline_add_widget zle-keymap-select _powerline_zle_keymap_select
_powerline_precmd
if [[ "$POWERLINE_MODE" != vi* ]] ; then
export POWERLINE_DEFAULT_MODE="$POWERLINE_MODE"
fi
trap "_powerline_tmux_set_columns" SIGWINCH
_powerline_tmux_set_columns
_powerline_tmux_set_pwd

View File

@ -44,19 +44,22 @@ def last_pipe_status(pl, segment_info):
@requires_segment_info
def mode(pl, segment_info, override={'vicmd': 'COMMND', 'viins': 'INSERT'}, default='main'):
def mode(pl, segment_info, override={'vicmd': 'COMMND', 'viins': 'INSERT'}, default=None):
'''Return the current mode.
:param dict override:
dict for overriding mode strings.
:param str default:
If current mode is equal to this string then this segment will not get
displayed.
displayed. If not specified the value is taken from
``$POWERLINE_DEFAULT_MODE`` variable. This variable is set by zsh
bindings for any mode that does not start from ``vi``.
'''
mode = segment_info['mode']
if not mode:
pl.warn('No or empty POWERLINE_MODE variable')
return None
default = default or segment_info['environ'].get('POWERLINE_DEFAULT_MODE')
if mode == default:
return None
try: