Merge branch 'bind_mode' of github.com:furunkel/fish-shell into bind_mode

This commit is contained in:
Julian Aron Prenner 2014-01-15 11:40:00 +01:00
commit 3a9173858b
2 changed files with 177 additions and 105 deletions

View File

@ -1,121 +1,123 @@
function fish_default_key_bindings -d "Default (Emacs-like) key bindings for fish"
function fish_default_key_bindings -d "Default (Emacs-like) key bindings for fish" -a mode
if not set -q mode[1]
# Clear earlier bindings, if any
bind --erase --all
end
# This is the default binding, i.e. the one used if no other binding matches
bind "" self-insert
bind $argv "" self-insert
bind \n execute
bind $argv \n execute
bind \ck kill-line
bind \cy yank
bind \t complete
bind $argv \ck kill-line
bind $argv \cy yank
bind $argv \t complete
bind \e\n "commandline -i \n"
bind $argv \e\n "commandline -i \n"
bind \e\[A up-or-search
bind \e\[B down-or-search
bind -k down down-or-search
bind -k up up-or-search
bind $argv \e\[A up-or-search
bind $argv \e\[B down-or-search
bind $argv -k down down-or-search
bind $argv -k up up-or-search
bind \e\[C forward-char
bind \e\[D backward-char
bind -k right forward-char
bind -k left backward-char
bind $argv \e\[C forward-char
bind $argv \e\[D backward-char
bind $argv -k right forward-char
bind $argv -k left backward-char
bind -k dc delete-char
bind -k backspace backward-delete-char
bind \x7f backward-delete-char
bind $argv -k dc delete-char
bind $argv -k backspace backward-delete-char
bind $argv \x7f backward-delete-char
bind \e\[H beginning-of-line
bind \e\[F end-of-line
bind $argv \e\[H beginning-of-line
bind $argv \e\[F end-of-line
# for PuTTY
# https://github.com/fish-shell/fish-shell/issues/180
bind \e\[1~ beginning-of-line
bind \e\[3~ delete-char
bind \e\[4~ end-of-line
bind $argv \e\[1~ beginning-of-line
bind $argv \e\[3~ delete-char
bind $argv \e\[4~ end-of-line
# OS X SnowLeopard doesn't have these keys. Don't show an annoying error message.
bind -k home beginning-of-line 2> /dev/null
bind -k end end-of-line 2> /dev/null
bind \e\[3\;2~ backward-delete-char # Mavericks Terminal.app shift-delete
bind $argv -k home beginning-of-line 2> /dev/null
bind $argv -k end end-of-line 2> /dev/null
bind $argv \e\[3\;2~ backward-delete-char # Mavericks Terminal.app shift-delete
bind \e\eOC nextd-or-forward-word
bind \e\eOD prevd-or-backward-word
bind \e\e\[C nextd-or-forward-word
bind \e\e\[D prevd-or-backward-word
bind \eO3C nextd-or-forward-word
bind \eO3D prevd-or-backward-word
bind \e\[3C nextd-or-forward-word
bind \e\[3D prevd-or-backward-word
bind \e\[1\;3C nextd-or-forward-word
bind \e\[1\;3D prevd-or-backward-word
bind $argv \e\eOC nextd-or-forward-word
bind $argv \e\eOD prevd-or-backward-word
bind $argv \e\e\[C nextd-or-forward-word
bind $argv \e\e\[D prevd-or-backward-word
bind $argv \eO3C nextd-or-forward-word
bind $argv \eO3D prevd-or-backward-word
bind $argv \e\[3C nextd-or-forward-word
bind $argv \e\[3D prevd-or-backward-word
bind $argv \e\[1\;3C nextd-or-forward-word
bind $argv \e\[1\;3D prevd-or-backward-word
bind \e\eOA history-token-search-backward
bind \e\eOB history-token-search-forward
bind \e\e\[A history-token-search-backward
bind \e\e\[B history-token-search-forward
bind \eO3A history-token-search-backward
bind \eO3B history-token-search-forward
bind \e\[3A history-token-search-backward
bind \e\[3B history-token-search-forward
bind \e\[1\;3A history-token-search-backward
bind \e\[1\;3B history-token-search-forward
bind $argv \e\eOA history-token-search-backward
bind $argv \e\eOB history-token-search-forward
bind $argv \e\e\[A history-token-search-backward
bind $argv \e\e\[B history-token-search-forward
bind $argv \eO3A history-token-search-backward
bind $argv \eO3B history-token-search-forward
bind $argv \e\[3A history-token-search-backward
bind $argv \e\[3B history-token-search-forward
bind $argv \e\[1\;3A history-token-search-backward
bind $argv \e\[1\;3B history-token-search-forward
bind \ca beginning-of-line
bind \ce end-of-line
bind \ey yank-pop
bind \ch backward-delete-char
bind \cw backward-kill-word
bind \cp history-search-backward
bind \cn history-search-forward
bind \cf forward-char
bind \cb backward-char
bind \ct transpose-chars
bind \et transpose-words
bind \eu upcase-word
bind $argv \ca beginning-of-line
bind $argv \ce end-of-line
bind $argv \ey yank-pop
bind $argv \ch backward-delete-char
bind $argv \cw backward-kill-word
bind $argv \cp history-search-backward
bind $argv \cn history-search-forward
bind $argv \cf forward-char
bind $argv \cb backward-char
bind $argv \ct transpose-chars
bind $argv \et transpose-words
bind $argv \eu upcase-word
# This clashes with __fish_list_current_token
# bind \el downcase-word
bind \ec capitalize-word
bind \e\x7f backward-kill-word
bind \eb backward-word
bind \ef forward-word
bind \e\[1\;5C forward-word
bind \e\[1\;5D backward-word
bind \e\[1\;9A history-token-search-backward # iTerm2
bind \e\[1\;9B history-token-search-forward # iTerm2
bind \e\[1\;9C forward-word #iTerm2
bind \e\[1\;9D backward-word #iTerm2
bind \ed forward-kill-word
bind -k ppage beginning-of-history
bind -k npage end-of-history
bind \e\< beginning-of-buffer
bind \e\> end-of-buffer
# bind $argv \el downcase-word
bind $argv \ec capitalize-word
bind $argv \e\x7f backward-kill-word
bind $argv \eb backward-word
bind $argv \ef forward-word
bind $argv \e\[1\;5C forward-word
bind $argv \e\[1\;5D backward-word
bind $argv \e\[1\;9A history-token-search-backward # iTerm2
bind $argv \e\[1\;9B history-token-search-forward # iTerm2
bind $argv \e\[1\;9C forward-word #iTerm2
bind $argv \e\[1\;9D backward-word #iTerm2
# Bash compatibility
# https://github.com/fish-shell/fish-shell/issues/89
bind $argv \e. history-token-search-backward
bind $argv -k ppage beginning-of-history
bind $argv -k npage end-of-history
bind $argv \e\< beginning-of-buffer
bind $argv \e\> end-of-buffer
bind \el __fish_list_current_token
bind \ew 'set tok (commandline -pt); if test $tok[1]; echo; whatis $tok[1]; commandline -f repaint; end'
bind \cl 'clear; commandline -f repaint'
bind \cc 'commandline ""'
bind \cu backward-kill-line
bind \ed kill-word
bind \cw backward-kill-path-component
bind \ed 'set -l cmd (commandline); if test -z "$cmd"; echo; dirh; commandline -f repaint; else; commandline -f kill-word; end'
bind \cd delete-or-exit
bind $argv \el __fish_list_current_token
bind $argv \ew 'set tok (commandline -pt); if test $tok[1]; echo; whatis $tok[1]; commandline -f repaint; end'
bind $argv \cl 'clear; commandline -f repaint'
bind $argv \cc 'commandline ""'
bind $argv \cu backward-kill-line
bind $argv \cw backward-kill-path-component
bind $argv \ed 'set -l cmd (commandline); if test -z "$cmd"; echo; dirh; commandline -f repaint; else; commandline -f kill-word; end'
bind $argv \cd delete-or-exit
# Allow reading manpages by pressing F1
bind -k f1 'man (basename (commandline -po; echo))[1] ^/dev/null; or echo -n \a'
bind $argv -k f1 'man (basename (commandline -po; echo))[1] ^/dev/null; or echo -n \a'
# This will make sure the output of the current command is paged using the less pager when you press Meta-p
bind \ep '__fish_paginate'
bind $argv \ep '__fish_paginate'
# term-specific special bindings
switch "$TERM"
case 'rxvt*'
bind \e\[8~ end-of-line
bind \eOc forward-word
bind \eOd backward-word
bind $argv \e\[8~ end-of-line
bind $argv \eOc forward-word
bind $argv \eOd backward-word
end
end

View File

@ -2,13 +2,21 @@ function fish_vi_key_bindings -d "vi-like key bindings for fish"
bind --erase --all
##
## command mode
##
#bind -m command : force-repaint
#bind -M command q exit
#bind -M command -m default \e force-repaint
#bind -M command -m default \cc force-repaint
bind :q exit
#
# command (default) mode
# normal (default) mode
#
bind \cd exit
bind :q exit
bind h backward-char
bind l forward-char
bind \e\[C forward-char
@ -17,10 +25,20 @@ function fish_vi_key_bindings -d "vi-like key bindings for fish"
bind -k left backward-char
bind \n execute
bind -m insert i force-repaint
bind -m insert I beginning-of-line force-repaint
bind -m insert a forward-char force-repaint
bind -m insert A end-of-line force-repaint
bind -m insert o "commandline -a \n" down-line force-repaint
#bind -m insert O beginning-of-line "commandline -i \n" up-line force-repaint # doesn't work
bind gg beginning-of-buffer
bind G end-of-buffer
bind \x24 end-of-line
bind \x5e beginning-of-line
bind g\x24 end-of-line
bind g\x5e beginning-of-line
bind \e\[H beginning-of-line
bind \e\[F end-of-line
@ -44,11 +62,59 @@ function fish_vi_key_bindings -d "vi-like key bindings for fish"
bind B backward-word
bind w forward-word
bind W backward-word
bind e forward-word
bind E backward-word
bind dd kill-line
bind x delete-char
bind X backward-delete-char
bind y yank
bind p yank-pop
bind -k dc delete-char
bind -k backspace backward-delete-char
bind \x7f backward-delete-char
bind \e\[3\;2~ backward-delete-char # Mavericks Terminal.app shift-delete
bind dd kill-whole-line
bind D kill-line
bind d\x24 kill-line
bind d\x5e backward-kill-line
bind dw kill-word
bind dW backward-kill-word
bind de kill-word
bind dE backward-kill-word
bind db backward-kill-word
bind dB kill-word
bind -m insert s delete-char force-repaint
bind -m insert S kill-whole-line force-repaint
bind -m insert cc kill-whole-line force-repaint
bind -m insert C kill-line force-repaint
bind -m insert c\x24 kill-line force-repaint
bind -m insert c\x5e backward-kill-line force-repaint
bind -m insert cw kill-word force-repaint
bind -m insert ce kill-word force-repaint
bind -m insert cb backward-kill-word force-repaint
bind '~' capitalize-word
bind gu downcase-word
bind gU upcase-word
bind J end-of-line delete-char
bind K 'man (basename (commandline -po; echo))[1] ^/dev/null; or echo -n \a'
bind yy kill-whole-line yank
bind Y kill-whole-line yank
bind y\x24 kill-line yank
bind y\x5e backward-kill-line yank
bind yw kill-word yank
bind yW backward-kill-word yank
bind ye kill-word yank
bind yE backward-kill-word yank
bind yb backward-kill-word yank
bind yB kill-word yank
bind p yank
bind P backward-char yank-pop
#
# insert mode
@ -78,4 +144,8 @@ function fish_vi_key_bindings -d "vi-like key bindings for fish"
bind -M insert -m default \cc force-repaint
bind -M insert -m default \e force-repaint
bind -M insert \cd exit
bind -M insert \ef forward-word
end