mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-27 05:13:10 +00:00
Merge branch 'bind_mode' of github.com:furunkel/fish-shell into bind_mode
This commit is contained in:
commit
45465e0c45
5 changed files with 61 additions and 50 deletions
|
@ -3,8 +3,8 @@
|
||||||
function __fish_complete_vi -d "Compleletions for vi and its aliases" --argument-names cmd
|
function __fish_complete_vi -d "Compleletions for vi and its aliases" --argument-names cmd
|
||||||
set -l is_vim
|
set -l is_vim
|
||||||
if type $cmd > /dev/null
|
if type $cmd > /dev/null
|
||||||
eval command $cmd --version >/dev/null ^/dev/null; and set -l is_vim vim
|
eval command $cmd --version >/dev/null ^/dev/null; and set -l is_vim vim
|
||||||
end
|
end
|
||||||
|
|
||||||
# vim
|
# vim
|
||||||
set -l cmds -c $cmd
|
set -l cmds -c $cmd
|
||||||
|
@ -24,11 +24,11 @@ function __fish_complete_vi -d "Compleletions for vi and its aliases" --argument
|
||||||
complete $cmds -s o -r --description 'Open stacked windows for each file'
|
complete $cmds -s o -r --description 'Open stacked windows for each file'
|
||||||
complete $cmds -s O -r --description 'Open side by side windows for each file'
|
complete $cmds -s O -r --description 'Open side by side windows for each file'
|
||||||
complete $cmds -s p -r --description 'Open tab pages for each file'
|
complete $cmds -s p -r --description 'Open tab pages for each file'
|
||||||
complete $cmds -s q -r --description 'Start in quickFix mode'
|
complete $cmds -s q -r --description 'Start in quickFix mode'
|
||||||
complete $cmds -s r -r --description 'Use swap files for recovery'
|
complete $cmds -s r -r --description 'Use swap files for recovery'
|
||||||
complete $cmds -s s -r --description 'Source and execute script file'
|
complete $cmds -s s -r --description 'Source and execute script file'
|
||||||
complete $cmds -s t -r --description 'Set the cursor to tag'
|
complete $cmds -s t -r --description 'Set the cursor to tag'
|
||||||
complete $cmds -s T -r --description 'Terminal name'
|
complete $cmds -s T -r --description 'Terminal name'
|
||||||
complete $cmds -s u -r --description 'Use alternative vimrc'
|
complete $cmds -s u -r --description 'Use alternative vimrc'
|
||||||
complete $cmds -s U -r --description 'Use alternative vimrc in GUI mode'
|
complete $cmds -s U -r --description 'Use alternative vimrc in GUI mode'
|
||||||
complete $cmds -s w -r --description 'Record all typed characters'
|
complete $cmds -s w -r --description 'Record all typed characters'
|
||||||
|
|
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,9 +1,9 @@
|
||||||
|
|
||||||
function fish_default_key_bindings -d "Default (Emacs-like) key bindings for fish" -a mode
|
function fish_default_key_bindings -d "Default (Emacs-like) key bindings for fish" -a mode
|
||||||
if not set -q mode[1]
|
if not set -q mode[1]
|
||||||
# Clear earlier bindings, if any
|
# Clear earlier bindings, if any
|
||||||
bind --erase --all
|
bind --erase --all
|
||||||
end
|
end
|
||||||
|
|
||||||
# This is the default binding, i.e. the one used if no other binding matches
|
# This is the default binding, i.e. the one used if no other binding matches
|
||||||
bind $argv "" self-insert
|
bind $argv "" self-insert
|
||||||
|
|
|
@ -1,59 +1,43 @@
|
||||||
function fish_vi_cursor -d 'Set cursor shape for different vi modes'
|
function fish_vi_cursor -d 'Set cursor shape for different vi modes'
|
||||||
set -l terminal $argv[1]
|
set -l terminal $argv[1]
|
||||||
set -q terminal[1]; or set terminal auto
|
set -q terminal[1]; or set terminal auto
|
||||||
|
set -l uses_echo
|
||||||
|
|
||||||
|
set fcn
|
||||||
switch "$terminal"
|
switch "$terminal"
|
||||||
case auto
|
case auto
|
||||||
if set -q KONSOLE_PROFILE_NAME
|
if set -q KONSOLE_PROFILE_NAME
|
||||||
set terminal konsole
|
set fcn __fish_cursor_konsole
|
||||||
|
set uses_echo 1
|
||||||
else if set -q XTERM_LOCALE
|
else if set -q XTERM_LOCALE
|
||||||
set terminal xterm
|
set fcn __fish_cursor_xterm
|
||||||
|
set uses_echo 1
|
||||||
else
|
else
|
||||||
#echo Not found
|
|
||||||
return 1
|
return 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
set -l command
|
set -l tmux_prefix
|
||||||
set -l start
|
set -l tmux_postfix
|
||||||
set -l end
|
if begin; set -q TMUX; and set -q uses_echo[1]; end
|
||||||
set -l shape_block
|
set tmux_prefix echo -ne "'\ePtmux;\e'"
|
||||||
set -l shape_line
|
set tmux_postfix echo -ne "'\e\\\\'"
|
||||||
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
|
end
|
||||||
if not set -q command[1]
|
|
||||||
#echo not found
|
set -q fish_cursor_unknown
|
||||||
return 1
|
or set -g fish_cursor_unknown block blink
|
||||||
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
|
|
||||||
|
|
||||||
echo "
|
echo "
|
||||||
function fish_vi_cursor_handle --on-variable fish_bind_mode
|
function fish_vi_cursor_handle --on-variable fish_bind_mode
|
||||||
switch \$fish_bind_mode
|
set -l varname fish_cursor_\$fish_bind_mode
|
||||||
case insert
|
if not set -q \$varname
|
||||||
$command \$fish_cursor_insert
|
set varname fish_cursor_unknown
|
||||||
case default
|
|
||||||
$command \$fish_cursor_default
|
|
||||||
case '*'
|
|
||||||
$command \$fish_cursor_other
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
" | source
|
#echo \$varname \$\$varname
|
||||||
|
$tmux_prefix
|
||||||
|
$fcn \$\$varname
|
||||||
|
$tmux_postfix
|
||||||
|
end
|
||||||
|
" | source
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue