2014-01-20 06:19:41 +00:00
|
|
|
function fish_vi_cursor -d 'Set cursor shape for different vi modes'
|
2023-11-14 17:09:04 +00:00
|
|
|
# if stdin is not a tty, there is effectively no bind mode.
|
|
|
|
if not test -t 0
|
2018-06-01 18:26:54 +00:00
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2019-05-05 15:31:33 +00: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 14:36:25 +00:00
|
|
|
set -q fish_cursor_unknown
|
2022-06-07 12:25:03 +00:00
|
|
|
or set -g fish_cursor_unknown block
|
2014-01-20 12:07:32 +00:00
|
|
|
|
2016-05-30 14:36:25 +00:00
|
|
|
echo "
|
2023-11-14 17:31:35 +00: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 14:36:25 +00:00
|
|
|
set -l varname fish_cursor_\$fish_bind_mode
|
|
|
|
if not set -q \$varname
|
|
|
|
set varname fish_cursor_unknown
|
|
|
|
end
|
2024-08-30 17:43:09 +00:00
|
|
|
__fish_cursor_xterm \$\$varname
|
2016-05-30 14:36:25 +00:00
|
|
|
end
|
|
|
|
" | source
|
2016-09-04 23:20:12 +00:00
|
|
|
|
|
|
|
echo "
|
|
|
|
function fish_vi_cursor_handle_preexec --on-event fish_preexec
|
2023-03-14 09:50:20 +00:00
|
|
|
set -l varname fish_cursor_external
|
|
|
|
if not set -q \$varname
|
|
|
|
set varname fish_cursor_default
|
|
|
|
end
|
2016-09-04 23:20:12 +00:00
|
|
|
if not set -q \$varname
|
|
|
|
set varname fish_cursor_unknown
|
|
|
|
end
|
2024-08-30 17:43:09 +00:00
|
|
|
__fish_cursor_xterm \$\$varname
|
2016-09-04 23:20:12 +00:00
|
|
|
end
|
|
|
|
" | source
|
2014-01-20 06:19:41 +00:00
|
|
|
end
|