2014-01-20 14:19:41 +08:00
|
|
|
function fish_vi_cursor -d 'Set cursor shape for different vi modes'
|
2023-11-15 01:09:04 +08:00
|
|
|
# if stdin is not a tty, there is effectively no bind mode.
|
|
|
|
if not test -t 0
|
2018-06-02 02:26:54 +08:00
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2019-05-05 23:31:33 +08:00
|
|
|
# This is hard to test in expect, since the exact sequences depend on the environment.
|
|
|
|
# Instead disable it.
|
|
|
|
if set -q FISH_UNIT_TESTS_RUNNING
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2016-05-30 22:36:25 +08:00
|
|
|
set -q fish_cursor_unknown
|
2022-06-07 20:25:03 +08:00
|
|
|
or set -g fish_cursor_unknown block
|
2014-01-20 20:07:32 +08:00
|
|
|
|
2016-05-30 22:36:25 +08:00
|
|
|
echo "
|
2023-11-15 01:31:35 +08:00
|
|
|
function fish_vi_cursor_handle --on-variable fish_bind_mode --on-event fish_postexec --on-event fish_focus_in --on-event fish_read
|
2016-05-30 22:36:25 +08:00
|
|
|
set -l varname fish_cursor_\$fish_bind_mode
|
|
|
|
if not set -q \$varname
|
|
|
|
set varname fish_cursor_unknown
|
|
|
|
end
|
2024-08-31 01:43:09 +08:00
|
|
|
__fish_cursor_xterm \$\$varname
|
2016-05-30 22:36:25 +08:00
|
|
|
end
|
|
|
|
" | source
|
2016-09-05 07:20:12 +08:00
|
|
|
|
|
|
|
echo "
|
|
|
|
function fish_vi_cursor_handle_preexec --on-event fish_preexec
|
2023-03-14 17:50:20 +08:00
|
|
|
set -l varname fish_cursor_external
|
|
|
|
if not set -q \$varname
|
|
|
|
set varname fish_cursor_default
|
|
|
|
end
|
2016-09-05 07:20:12 +08:00
|
|
|
if not set -q \$varname
|
|
|
|
set varname fish_cursor_unknown
|
|
|
|
end
|
2024-08-31 01:43:09 +08:00
|
|
|
__fish_cursor_xterm \$\$varname
|
2016-09-05 07:20:12 +08:00
|
|
|
end
|
|
|
|
" | source
|
2014-01-20 14:19:41 +08:00
|
|
|
end
|