diff --git a/powerline/bindings/zsh/powerline.zsh b/powerline/bindings/zsh/powerline.zsh index ec4ebab8..6b55f1c3 100644 --- a/powerline/bindings/zsh/powerline.zsh +++ b/powerline/bindings/zsh/powerline.zsh @@ -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 diff --git a/powerline/segments/shell.py b/powerline/segments/shell.py index 962a1a26..1245d109 100644 --- a/powerline/segments/shell.py +++ b/powerline/segments/shell.py @@ -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: