fish_right_prompt.fish (2694B)
1 # right prompt for agnoster theme 2 # shows vim mode status 3 4 # =========================== 5 # Color setting 6 7 # You can set these variables in config.fish like: 8 # set -g color_dir_bg red 9 # If not set, default color from agnoster will be used. 10 # =========================== 11 set -q color_vi_mode_indicator; or set color_vi_mode_indicator black 12 set -q color_vi_mode_normal; or set color_vi_mode_normal green 13 set -q color_vi_mode_insert; or set color_vi_mode_insert blue 14 set -q color_vi_mode_visual; or set color_vi_mode_visual red 15 16 17 # =========================== 18 # Cursor setting 19 20 # You can set these variables in config.fish like: 21 # set -g cursor_vi_mode_insert bar_blinking 22 # =========================== 23 set -q cursor_vi_mode_normal; or set cursor_vi_mode_normal box_steady 24 set -q cursor_vi_mode_insert; or set cursor_vi_mode_insert bar_steady 25 set -q cursor_vi_mode_visual; or set cursor_vi_mode_visual box_steady 26 27 28 function fish_cursor_name_to_code -a cursor_name -d "Translate cursor name to a cursor code" 29 # these values taken from 30 # https://github.com/gnachman/iTerm2/blob/master/sources/VT100Terminal.m#L1646 31 # Beginning with the statement "case VT100CSI_DECSCUSR:" 32 if [ $cursor_name = "box_blinking" ] 33 echo 1 34 else if [ $cursor_name = "box_steady" ] 35 echo 2 36 else if [ $cursor_name = "underline_blinking" ] 37 echo 3 38 else if [ $cursor_name = "underline_steady" ] 39 echo 4 40 else if [ $cursor_name = "bar_blinking" ] 41 echo 5 42 else if [ $cursor_name = "bar_steady" ] 43 echo 6 44 else 45 echo 2 46 end 47 end 48 49 function prompt_vi_mode -d 'vi mode status indicator' 50 set -l right_segment_separator \uE0B2 51 switch $fish_bind_mode 52 case default 53 set -l mode (fish_cursor_name_to_code $cursor_vi_mode_normal) 54 echo -e "\e[\x3$mode q" 55 set_color $color_vi_mode_normal 56 echo "$right_segment_separator" 57 set_color -b $color_vi_mode_normal $color_vi_mode_indicator 58 echo " N " 59 case insert 60 set -l mode (fish_cursor_name_to_code $cursor_vi_mode_insert) 61 echo -e "\e[\x3$mode q" 62 set_color $color_vi_mode_insert 63 echo "$right_segment_separator" 64 set_color -b $color_vi_mode_insert $color_vi_mode_indicator 65 echo " I " 66 case visual 67 set -l mode (fish_cursor_name_to_code $cursor_vi_mode_visual) 68 echo -e "\e[\x3$mode q" 69 set_color $color_vi_mode_visual 70 echo "$right_segment_separator" 71 set_color -b $color_vi_mode_visual $color_vi_mode_indicator 72 echo " V " 73 end 74 end 75 76 function fish_right_prompt -d 'Prints right prompt' 77 if not test "$fish_key_bindings" = "fish_default_key_bindings" 78 prompt_vi_mode 79 set_color normal 80 end 81 end