Fix key binding mode indicator in newer Fish

Unfortunately this means we can't have a pretty arrow between the binding mode indicator and the rest of the prompt, but it's better than never updating the indicator :-/

Fixes #248
pull/172/merge
Justin Hileman 4 years ago
parent 9dd917535a
commit e4c6a5c434

@ -1,9 +1,42 @@
# This is handled inside fish_mode_prompt (see `__bobthefish_prompt_vi`)
# Display the current binding mode... if it's vi or vi-like.
#
# If you want to override this with your own mode prompt, disable bobthefish's
# built-in mode prompt in your fish config:
# To always show the binding mode (regardless of current bindings):
# set -g theme_display_vi yes
#
# To never show:
# set -g theme_display_vi no
function fish_mode_prompt
function fish_mode_prompt -d 'bobthefish-optimized fish mode indicator'
[ "$theme_display_vi" != 'no' ]
or return
[ "$fish_key_bindings" = 'fish_vi_key_bindings' \
-o "$fish_key_bindings" = 'hybrid_bindings' \
-o "$fish_key_bindings" = 'fish_hybrid_key_bindings' \
-o "$theme_display_vi" = 'yes' ]
or return
__bobthefish_colors $theme_color_scheme
type -q bobthefish_colors
and bobthefish_colors
set_color normal # clear out anything bold or underline...
switch $fish_bind_mode
case default
set_color -b $color_vi_mode_default
echo -n ' N '
case insert
set_color -b $color_vi_mode_insert
echo -n ' I '
case replace_one replace-one
set_color -b $color_vi_mode_insert
echo -n ' R '
case visual
set_color -b $color_vi_mode_visual
echo -n ' V '
end
set_color normal
end

@ -407,7 +407,7 @@ end
# ==============================
# Status and input mode segments
# Status segment
# ==============================
function __bobthefish_prompt_status -S -a last_status -d 'Display flags for a non-zero exit status, root user, and background jobs'
@ -485,32 +485,6 @@ function __bobthefish_prompt_status -S -a last_status -d 'Display flags for a no
end
end
function __bobthefish_prompt_vi -S -d 'Display vi mode'
[ "$theme_display_vi" != 'no' ]
or return
[ "$fish_key_bindings" = 'fish_vi_key_bindings' \
-o "$fish_key_bindings" = 'hybrid_bindings' \
-o "$fish_key_bindings" = 'fish_hybrid_key_bindings' \
-o "$theme_display_vi" = 'yes' ]
or return
switch $fish_bind_mode
case default
__bobthefish_start_segment $color_vi_mode_default
echo -n 'N '
case insert
__bobthefish_start_segment $color_vi_mode_insert
echo -n 'I '
case replace_one replace-one
__bobthefish_start_segment $color_vi_mode_insert
echo -n 'R '
case visual
__bobthefish_start_segment $color_vi_mode_visual
echo -n 'V '
end
end
# ==============================
# Container and VM segments
@ -1071,7 +1045,6 @@ function fish_prompt -d 'bobthefish, a fish theme optimized for awesome'
# Status flags and input mode
__bobthefish_prompt_status $last_status
__bobthefish_prompt_vi
# User / hostname info
__bobthefish_prompt_user

Loading…
Cancel
Save