2007-09-26 00:14:47 +08:00
|
|
|
|
2014-01-15 15:26:38 +08:00
|
|
|
function fish_default_key_bindings -d "Default (Emacs-like) key bindings for fish" -a mode
|
2014-01-20 21:03:46 +08:00
|
|
|
if not set -q mode[1]
|
|
|
|
# Clear earlier bindings, if any
|
|
|
|
bind --erase --all
|
|
|
|
end
|
2010-09-18 10:18:26 +08:00
|
|
|
|
2007-09-26 00:14:47 +08:00
|
|
|
# This is the default binding, i.e. the one used if no other binding matches
|
2014-01-15 15:26:38 +08:00
|
|
|
bind $argv "" self-insert
|
2007-09-26 00:14:47 +08:00
|
|
|
|
2014-01-15 15:26:38 +08:00
|
|
|
bind $argv \n execute
|
2015-12-01 07:44:51 +08:00
|
|
|
bind $argv \r execute
|
2007-09-26 00:14:47 +08:00
|
|
|
|
2014-01-15 15:26:38 +08:00
|
|
|
bind $argv \ck kill-line
|
|
|
|
bind $argv \cy yank
|
|
|
|
bind $argv \t complete
|
2010-09-18 10:18:26 +08:00
|
|
|
|
2014-01-15 15:26:38 +08:00
|
|
|
bind $argv \e\n "commandline -i \n"
|
2016-03-21 03:00:34 +08:00
|
|
|
bind $argv \e\r "commandline -i \n"
|
2010-09-18 10:18:26 +08:00
|
|
|
|
2014-01-15 15:26:38 +08:00
|
|
|
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
|
2010-09-18 10:18:26 +08:00
|
|
|
|
2015-09-01 17:46:54 +08:00
|
|
|
# Some linux VTs output these (why?)
|
|
|
|
bind $argv \eOA up-or-search
|
|
|
|
bind $argv \eOB down-or-search
|
|
|
|
bind $argv \eOC forward-char
|
|
|
|
bind $argv \eOD backward-char
|
|
|
|
|
2014-01-15 15:26:38 +08:00
|
|
|
bind $argv \e\[C forward-char
|
|
|
|
bind $argv \e\[D backward-char
|
|
|
|
bind $argv -k right forward-char
|
|
|
|
bind $argv -k left backward-char
|
2010-09-18 10:18:26 +08:00
|
|
|
|
2014-01-15 15:26:38 +08:00
|
|
|
bind $argv -k dc delete-char
|
|
|
|
bind $argv -k backspace backward-delete-char
|
|
|
|
bind $argv \x7f backward-delete-char
|
2010-09-18 10:18:26 +08:00
|
|
|
|
2014-01-15 15:26:38 +08:00
|
|
|
bind $argv \e\[H beginning-of-line
|
|
|
|
bind $argv \e\[F end-of-line
|
2012-05-30 15:22:45 +08:00
|
|
|
|
2013-11-13 11:20:59 +08:00
|
|
|
# for PuTTY
|
|
|
|
# https://github.com/fish-shell/fish-shell/issues/180
|
2014-01-15 15:26:38 +08:00
|
|
|
bind $argv \e\[1~ beginning-of-line
|
|
|
|
bind $argv \e\[3~ delete-char
|
|
|
|
bind $argv \e\[4~ end-of-line
|
2013-11-13 11:20:59 +08:00
|
|
|
|
2012-05-30 15:22:45 +08:00
|
|
|
# OS X SnowLeopard doesn't have these keys. Don't show an annoying error message.
|
2014-01-15 15:26:38 +08:00
|
|
|
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 $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 $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 $argv \ca beginning-of-line
|
|
|
|
bind $argv \ce end-of-line
|
|
|
|
bind $argv \ey yank-pop
|
|
|
|
bind $argv \ch backward-delete-char
|
2015-07-15 08:57:37 +08:00
|
|
|
bind $argv \cp up-or-search
|
|
|
|
bind $argv \cn down-or-search
|
2014-01-15 15:26:38 +08:00
|
|
|
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
|
2014-01-15 22:27:06 +08:00
|
|
|
|
2013-09-10 00:46:16 +08:00
|
|
|
# This clashes with __fish_list_current_token
|
2014-01-15 15:26:38 +08:00
|
|
|
# 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
|
2015-08-25 19:49:40 +08:00
|
|
|
bind $argv \e\[1\;9C nextd-or-forward-word #iTerm2
|
|
|
|
bind $argv \e\[1\;9D prevd-or-backward-word #iTerm2
|
2014-01-15 15:26:38 +08:00
|
|
|
# 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 $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'
|
2016-04-14 10:46:18 +08:00
|
|
|
bind $argv \cc __fish_cancel_commandline
|
2014-01-15 15:26:38 +08:00
|
|
|
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
|
2010-09-18 10:18:26 +08:00
|
|
|
|
2007-09-26 00:14:47 +08:00
|
|
|
bind \ed forward-kill-word
|
|
|
|
bind \ed kill-word
|
2010-09-18 10:18:26 +08:00
|
|
|
|
2014-09-28 17:09:14 +08:00
|
|
|
# Allow reading manpages by pressing F1 (many GUI applications) or Alt+h (like in zsh)
|
|
|
|
bind $argv -k f1 __fish_man_page
|
|
|
|
bind $argv \eh __fish_man_page
|
2013-10-28 00:30:07 +08:00
|
|
|
|
2015-10-29 14:51:17 +08:00
|
|
|
# This will make sure the output of the current command is paged using the default pager when you press Meta-p
|
|
|
|
# If none is set, less will be used
|
2014-01-15 15:26:38 +08:00
|
|
|
bind $argv \ep '__fish_paginate'
|
2013-04-29 05:36:11 +08:00
|
|
|
|
2014-01-27 16:56:13 +08:00
|
|
|
# shift-tab does a tab complete followed by a search
|
2014-01-27 18:17:31 +08:00
|
|
|
bind --key btab complete-and-search
|
|
|
|
|
|
|
|
# escape cancels stuff
|
|
|
|
bind \e cancel
|
2014-01-27 16:56:13 +08:00
|
|
|
|
2015-01-30 16:01:25 +08:00
|
|
|
# Ignore some known-bad control sequences
|
|
|
|
# https://github.com/fish-shell/fish-shell/issues/1917
|
|
|
|
bind \e\[I 'begin;end'
|
|
|
|
bind \e\[O 'begin;end'
|
|
|
|
|
2013-04-29 05:36:11 +08:00
|
|
|
# term-specific special bindings
|
|
|
|
switch "$TERM"
|
|
|
|
case 'rxvt*'
|
2014-01-15 15:26:38 +08:00
|
|
|
bind $argv \e\[8~ end-of-line
|
|
|
|
bind $argv \eOc forward-word
|
|
|
|
bind $argv \eOd backward-word
|
2013-04-29 05:36:11 +08:00
|
|
|
end
|
2014-01-27 16:56:13 +08:00
|
|
|
|
2016-04-17 11:03:14 +08:00
|
|
|
# Make it easy to turn an unexecuted command into a comment in the shell history. Also,
|
|
|
|
# remove the commenting chars so the command can be further edited then executed.
|
|
|
|
bind \e\# __fish_toggle_comment_commandline
|
|
|
|
end
|