mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-04-27 06:31:19 -03:00
Historically, ctrl-i sends the same code as tab, ctrl-h sends backspace and ctrl-j and ctrl-m behave like enter. Even for terminals that send unambiguous encodings (via the kitty keyboard protocol), we have kept bindings like ctrl-h, to support existing habits. We forgot that pressing alt-ctrl-h would behave like alt-backspace (and can be easier to reach) so maybe we should add that as well. Don't add ctrl-shift-i because at least on Linux, that's usually intercepted by the terminal emulator. Technically there are some more such as "ctrl-2" (which used to do the same as "ctrl-space") but I don't think anyone uses that over "ctrl-space". Closes #https://github.com/fish-shell/fish-shell/discussions/11548
80 lines
2.9 KiB
Fish
80 lines
2.9 KiB
Fish
function fish_default_key_bindings -d "emacs-like key binds"
|
|
if contains -- -h $argv
|
|
or contains -- --help $argv
|
|
echo "Sorry but this function doesn't support -h or --help"
|
|
return 1
|
|
end
|
|
|
|
if not set -q argv[1]
|
|
bind --erase --all --preset # clear earlier bindings, if any
|
|
if test "$fish_key_bindings" != fish_default_key_bindings
|
|
__fish_change_key_bindings fish_default_key_bindings || return
|
|
set fish_bind_mode default
|
|
end
|
|
end
|
|
|
|
# Silence warnings about unavailable keys. See #4431, 4188
|
|
if not contains -- -s $argv
|
|
set argv -s $argv
|
|
end
|
|
|
|
# These are shell-specific bindings that we share with vi mode.
|
|
__fish_shared_key_bindings $argv
|
|
or return # protect against invalid $argv
|
|
|
|
bind --preset $argv right forward-char
|
|
bind --preset $argv left backward-char
|
|
|
|
bind --preset $argv delete delete-char
|
|
bind --preset $argv backspace backward-delete-char
|
|
bind --preset $argv shift-backspace backward-delete-char
|
|
|
|
bind --preset $argv home beginning-of-line
|
|
bind --preset $argv end end-of-line
|
|
|
|
bind --preset $argv ctrl-a beginning-of-line
|
|
bind --preset $argv ctrl-e end-of-line
|
|
bind --preset $argv ctrl-h backward-delete-char
|
|
bind --preset $argv ctrl-p up-or-search
|
|
bind --preset $argv ctrl-n down-or-search
|
|
bind --preset $argv ctrl-f forward-char
|
|
bind --preset $argv ctrl-b backward-char
|
|
bind --preset $argv ctrl-t transpose-chars
|
|
bind --preset $argv ctrl-g cancel
|
|
bind --preset $argv ctrl-/ undo
|
|
bind --preset $argv ctrl-_ undo # XTerm idiosyncracy, can get rid of this once we go full CSI u
|
|
bind --preset $argv ctrl-z undo
|
|
bind --preset $argv ctrl-shift-z redo
|
|
bind --preset $argv alt-/ redo
|
|
bind --preset $argv alt-t transpose-words
|
|
bind --preset $argv alt-u upcase-word
|
|
|
|
bind --preset $argv alt-c capitalize-word
|
|
if test (__fish_uname) = Darwin
|
|
bind --preset $argv alt-backspace backward-kill-word
|
|
bind --preset $argv ctrl-alt-h backward-kill-word
|
|
bind --preset $argv ctrl-backspace backward-kill-token
|
|
bind --preset $argv alt-delete kill-word
|
|
bind --preset $argv ctrl-delete kill-token
|
|
else
|
|
bind --preset $argv alt-backspace backward-kill-token
|
|
bind --preset $argv ctrl-alt-h backward-kill-token
|
|
bind --preset $argv ctrl-backspace backward-kill-word
|
|
bind --preset $argv alt-delete kill-token
|
|
bind --preset $argv ctrl-delete kill-word
|
|
end
|
|
|
|
bind --preset $argv alt-\< beginning-of-buffer
|
|
bind --preset $argv alt-\> end-of-buffer
|
|
|
|
bind --preset $argv ctrl-r history-pager
|
|
|
|
# term-specific special bindings
|
|
switch "$TERM"
|
|
case xterm-256color
|
|
# Microsoft's conemu uses xterm-256color plus
|
|
# the following to tell a console to paste:
|
|
bind --preset $argv \e\x20ep fish_clipboard_paste
|
|
end
|
|
end
|