mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-13 05:28:49 +00:00
More clear way of setting cursor shape
This commit is contained in:
parent
44c6fa68cf
commit
3591900070
3 changed files with 52 additions and 53 deletions
11
share/functions/__fish_cursor_konsole.fish
Normal file
11
share/functions/__fish_cursor_konsole.fish
Normal file
|
@ -0,0 +1,11 @@
|
|||
function __fish_cursor_konsole -d 'Set cursor (konsole)'
|
||||
set -l shape $argv[1]
|
||||
switch "$shape"
|
||||
case block
|
||||
echo -en '\e]50;CursorShape=0\x7'
|
||||
case underscore
|
||||
echo -en '\e]50;CursorShape=2\x7'
|
||||
case line
|
||||
echo -en '\e]50;CursorShape=1\x7'
|
||||
end
|
||||
end
|
16
share/functions/__fish_cursor_xterm.fish
Normal file
16
share/functions/__fish_cursor_xterm.fish
Normal file
|
@ -0,0 +1,16 @@
|
|||
function __fish_cursor_xterm -d 'Set cursor (xterm)'
|
||||
set -l shape $argv[1]
|
||||
|
||||
switch "$shape"
|
||||
case block
|
||||
set shape 2
|
||||
case underscore
|
||||
set shape 4
|
||||
case line
|
||||
set shape 6
|
||||
end
|
||||
if contains blink $argv
|
||||
set shape (expr $shape - 1)
|
||||
end
|
||||
echo -en "\e[$shape q"
|
||||
end
|
|
@ -1,59 +1,31 @@
|
|||
function fish_vi_cursor -d 'Set cursor shape for different vi modes'
|
||||
set -l terminal $argv[1]
|
||||
set -q terminal[1]; or set terminal auto
|
||||
set -l terminal $argv[1]
|
||||
set -q terminal[1]; or set terminal auto
|
||||
|
||||
switch "$terminal"
|
||||
case auto
|
||||
if set -q KONSOLE_PROFILE_NAME
|
||||
set terminal konsole
|
||||
else if set -q XTERM_LOCALE
|
||||
set terminal xterm
|
||||
else
|
||||
#echo Not found
|
||||
return 1
|
||||
set fcn
|
||||
switch "$terminal"
|
||||
case auto
|
||||
if set -q KONSOLE_PROFILE_NAME
|
||||
set fcn __fish_cursor_konsole
|
||||
else if set -q XTERM_LOCALE
|
||||
set fcn __fish_cursor_xterm
|
||||
else
|
||||
return 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
set -l command
|
||||
set -l start
|
||||
set -l end
|
||||
set -l shape_block
|
||||
set -l shape_line
|
||||
set -l shape_underline
|
||||
switch "$terminal"
|
||||
case konsole iterm
|
||||
set command echo -en
|
||||
set start "\e]50;"
|
||||
set end "\x7"
|
||||
set shape_block 'CursorShape=0'
|
||||
set shape_line 'CursorShape=1'
|
||||
set shape_underline 'CursorShape=2'
|
||||
case xterm
|
||||
set command echo -en
|
||||
set start '\e['
|
||||
set end ' q'
|
||||
set shape_block '2'
|
||||
set shape_underline '4'
|
||||
set shape_line '6'
|
||||
end
|
||||
if not set -q command[1]
|
||||
#echo not found
|
||||
return 1
|
||||
end
|
||||
set -g fish_cursor_insert $start$shape_line$end
|
||||
set -g fish_cursor_default $start$shape_block$end
|
||||
set -g fish_cursor_other $start$shape_block$end
|
||||
set -g fish_cursor_insert line
|
||||
set -g fish_cursor_default block
|
||||
set -g fish_cursor_unknown block blink
|
||||
|
||||
echo "
|
||||
function fish_vi_cursor_handle --on-variable fish_bind_mode
|
||||
switch \$fish_bind_mode
|
||||
case insert
|
||||
$command \$fish_cursor_insert
|
||||
case default
|
||||
$command \$fish_cursor_default
|
||||
case '*'
|
||||
$command \$fish_cursor_other
|
||||
end
|
||||
end
|
||||
" | source
|
||||
echo "
|
||||
function fish_cursor_vi_handle --on-variable fish_bind_mode
|
||||
set -l varname fish_cursor_\$fish_bind_mode
|
||||
if not set -q \$varname
|
||||
set varname fish_cursor_unknown
|
||||
end
|
||||
#echo \$varname \$\$varname
|
||||
$fcn \$\$varname
|
||||
end
|
||||
" | source
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue