From 0e97b876eabd9d02836c6b433bbbdbd278949652 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Fri, 25 Oct 2024 22:47:20 +0200 Subject: [PATCH] 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. --- share/functions/fish_vi_cursor.fish | 38 +++++++++++++---------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/share/functions/fish_vi_cursor.fish b/share/functions/fish_vi_cursor.fish index b446cb15d..7e7b86db4 100644 --- a/share/functions/fish_vi_cursor.fish +++ b/share/functions/fish_vi_cursor.fish @@ -7,26 +7,22 @@ function fish_vi_cursor -d 'Set cursor shape for different vi modes' set -q fish_cursor_unknown or set -g fish_cursor_unknown block - echo " - function fish_vi_cursor_handle --on-variable fish_bind_mode --on-event fish_postexec --on-event fish_focus_in --on-event fish_read - set -l varname fish_cursor_\$fish_bind_mode - if not set -q \$varname - set varname fish_cursor_unknown - end - __fish_cursor_xterm \$\$varname - end - " | source + function __fish_vi_cursor --argument-names varname + if not set -q $varname + set varname fish_cursor_unknown + end + __fish_cursor_xterm $$varname + end - echo " - function fish_vi_cursor_handle_preexec --on-event fish_preexec - set -l varname fish_cursor_external - if not set -q \$varname - set varname fish_cursor_default - end - if not set -q \$varname - set varname fish_cursor_unknown - end - __fish_cursor_xterm \$\$varname - end - " | source + function fish_vi_cursor_handle --on-variable fish_bind_mode --on-event fish_postexec --on-event fish_focus_in --on-event fish_read + __fish_vi_cursor fish_cursor_$fish_bind_mode + end + + function fish_vi_cursor_handle_preexec --on-event fish_preexec + set -l varname fish_cursor_external + if not set -q \$varname + set varname fish_cursor_default + end + __fish_vi_cursor $varname + end end