Simplify fish_vi_cursor

This command has redundant source statements which need a lot
of escaping. Also, let's extract a function, to be modified in a
following commit.
This commit is contained in:
Johannes Altmanninger 2024-10-25 22:47:20 +02:00
parent aca8058717
commit 0e97b876ea

View file

@ -7,26 +7,22 @@ function fish_vi_cursor -d 'Set cursor shape for different vi modes'
set -q fish_cursor_unknown set -q fish_cursor_unknown
or set -g fish_cursor_unknown block or set -g fish_cursor_unknown block
echo " function __fish_vi_cursor --argument-names varname
function fish_vi_cursor_handle --on-variable fish_bind_mode --on-event fish_postexec --on-event fish_focus_in --on-event fish_read if not set -q $varname
set -l varname fish_cursor_\$fish_bind_mode set varname fish_cursor_unknown
if not set -q \$varname end
set varname fish_cursor_unknown __fish_cursor_xterm $$varname
end end
__fish_cursor_xterm \$\$varname
end
" | source
echo " function fish_vi_cursor_handle --on-variable fish_bind_mode --on-event fish_postexec --on-event fish_focus_in --on-event fish_read
function fish_vi_cursor_handle_preexec --on-event fish_preexec __fish_vi_cursor fish_cursor_$fish_bind_mode
set -l varname fish_cursor_external end
if not set -q \$varname
set varname fish_cursor_default function fish_vi_cursor_handle_preexec --on-event fish_preexec
end set -l varname fish_cursor_external
if not set -q \$varname if not set -q \$varname
set varname fish_cursor_unknown set varname fish_cursor_default
end end
__fish_cursor_xterm \$\$varname __fish_vi_cursor $varname
end end
" | source
end end