mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-07 10:01:14 -03:00
Remove "bind -k" terminfo key names, update "bind --key-names"
I don't think there's a relevant terminal where the "bind -k" notation is still needed. The remaining reason to keep it is backwards compatibility. But "bind -k" is already subtly broken on terminals that implement either of modifyOtherKeys, application keypad mode or the kitty keyboard protocol, since those alter the byte sequences (see #11278). Having it randomly not work might do more harm than good. Remove it. This is meant go into 4.1, which means that users who switch back and forth between 4.1 and 4.0 can already use the new notation. If someone wants to use the bind config for a wider range of versions they could use "bind -k 2>/dev/null" etc. While at it, use the new key names in "bind --key-names", and sort it like we do in "bind --function-names". Closes #11342
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
function __fish_shared_key_bindings -d "Bindings shared between emacs and vi mode"
|
||||
set -l legacy_bind bind
|
||||
# These are some bindings that are supposed to be shared between vi mode and default mode.
|
||||
# They are supposed to be unrelated to text-editing (or movement).
|
||||
# This takes $argv so the vi-bindings can pass the mode they are valid in.
|
||||
@@ -17,8 +16,6 @@ function __fish_shared_key_bindings -d "Bindings shared between emacs and vi mod
|
||||
# Left/Right arrow
|
||||
bind --preset $argv right forward-char
|
||||
bind --preset $argv left backward-char
|
||||
$legacy_bind --preset $argv -k right forward-char
|
||||
$legacy_bind --preset $argv -k left backward-char
|
||||
|
||||
# Ctrl-left/right - these also work in vim.
|
||||
if test (__fish_uname) = Darwin
|
||||
@@ -31,8 +28,6 @@ function __fish_shared_key_bindings -d "Bindings shared between emacs and vi mod
|
||||
|
||||
bind --preset $argv pageup beginning-of-history
|
||||
bind --preset $argv pagedown end-of-history
|
||||
$legacy_bind --preset $argv -k ppage beginning-of-history
|
||||
$legacy_bind --preset $argv -k npage end-of-history
|
||||
|
||||
# Interaction with the system clipboard.
|
||||
bind --preset $argv ctrl-x fish_clipboard_copy
|
||||
@@ -45,19 +40,13 @@ function __fish_shared_key_bindings -d "Bindings shared between emacs and vi mod
|
||||
bind --preset $argv ctrl-s pager-toggle-search
|
||||
# shift-tab does a tab complete followed by a search.
|
||||
bind --preset $argv shift-tab complete-and-search
|
||||
$legacy_bind --preset $argv -k btab complete-and-search
|
||||
bind --preset $argv shift-delete history-delete or backward-delete-char
|
||||
$legacy_bind --preset $argv -k sdc history-delete or backward-delete-char
|
||||
|
||||
bind --preset $argv down down-or-search
|
||||
$legacy_bind --preset $argv -k down down-or-search
|
||||
bind --preset $argv up up-or-search
|
||||
$legacy_bind --preset $argv -k up up-or-search
|
||||
|
||||
bind --preset $argv shift-right forward-bigword
|
||||
bind --preset $argv shift-left backward-bigword
|
||||
$legacy_bind --preset $argv -k sright forward-bigword
|
||||
$legacy_bind --preset $argv -k sleft backward-bigword
|
||||
|
||||
set -l alt_right_aliases alt-right \e\[1\;9C # iTerm2 < 3.5.12
|
||||
set -l alt_left_aliases alt-left \e\[1\;9D # iTerm2 < 3.5.12
|
||||
@@ -79,8 +68,8 @@ function __fish_shared_key_bindings -d "Bindings shared between emacs and vi mod
|
||||
|
||||
bind --preset $argv alt-up history-token-search-backward
|
||||
bind --preset $argv alt-down history-token-search-forward
|
||||
$legacy_bind --preset $argv \e\[1\;9A history-token-search-backward # iTerm2 < 3.5.12
|
||||
$legacy_bind --preset $argv \e\[1\;9B history-token-search-forward # iTerm2 < 3.5.12
|
||||
bind --preset $argv \e\[1\;9A history-token-search-backward # iTerm2 < 3.5.12
|
||||
bind --preset $argv \e\[1\;9B history-token-search-forward # iTerm2 < 3.5.12
|
||||
# Bash compatibility
|
||||
# https://github.com/fish-shell/fish-shell/issues/89
|
||||
bind --preset $argv alt-. history-token-search-backward
|
||||
@@ -103,7 +92,6 @@ function __fish_shared_key_bindings -d "Bindings shared between emacs and vi mod
|
||||
|
||||
# Allow reading manpages by pressing f1 (many GUI applications) or Alt+h (like in zsh).
|
||||
bind --preset $argv f1 __fish_man_page
|
||||
$legacy_bind --preset $argv -k f1 __fish_man_page
|
||||
bind --preset $argv alt-h __fish_man_page
|
||||
|
||||
# This will make sure the output of the current command is paged using the default pager when
|
||||
@@ -139,7 +127,6 @@ function __fish_shared_key_bindings -d "Bindings shared between emacs and vi mod
|
||||
bind --preset $argv alt-enter "commandline -i \n $maybe_search_field" expand-abbr
|
||||
bind --preset $argv ")" self-insert expand-abbr # Closing a command substitution.
|
||||
bind --preset $argv ctrl-space 'test -n "$(commandline)" && commandline -i " " '$maybe_search_field
|
||||
$legacy_bind --preset $argv -k nul 'test -n "$(commandline)" && commandline -i " " '$maybe_search_field
|
||||
# Shift-space behaves like space because it's easy to mistype.
|
||||
bind --preset $argv shift-space 'commandline -i " " '$maybe_search_field expand-abbr
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
function fish_default_key_bindings -d "emacs-like key binds"
|
||||
set -l legacy_bind bind
|
||||
if contains -- -h $argv
|
||||
or contains -- --help $argv
|
||||
echo "Sorry but this function doesn't support -h or --help"
|
||||
@@ -25,17 +24,13 @@ function fish_default_key_bindings -d "emacs-like key binds"
|
||||
|
||||
bind --preset $argv right forward-char
|
||||
bind --preset $argv left backward-char
|
||||
$legacy_bind --preset $argv -k right forward-char
|
||||
$legacy_bind --preset $argv -k 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
|
||||
$legacy_bind --preset $argv -k home beginning-of-line
|
||||
bind --preset $argv end end-of-line
|
||||
$legacy_bind --preset $argv -k end end-of-line
|
||||
|
||||
bind --preset $argv ctrl-a beginning-of-line
|
||||
bind --preset $argv ctrl-e end-of-line
|
||||
@@ -79,6 +74,6 @@ function fish_default_key_bindings -d "emacs-like key binds"
|
||||
case xterm-256color
|
||||
# Microsoft's conemu uses xterm-256color plus
|
||||
# the following to tell a console to paste:
|
||||
$legacy_bind --preset $argv \e\x20ep fish_clipboard_paste
|
||||
bind --preset $argv \e\x20ep fish_clipboard_paste
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
function fish_vi_key_bindings --description 'vi-like key bindings for fish'
|
||||
set -l legacy_bind bind
|
||||
if contains -- -h $argv
|
||||
or contains -- --help $argv
|
||||
echo "Sorry but this function doesn't support -h or --help" >&2
|
||||
@@ -110,13 +109,9 @@ function fish_vi_key_bindings --description 'vi-like key bindings for fish'
|
||||
|
||||
# Vi/Vim doesn't support these keys in insert mode but that seems silly so we do so anyway.
|
||||
bind -s --preset -M insert home beginning-of-line
|
||||
$legacy_bind -s --preset -M insert -k home beginning-of-line
|
||||
bind -s --preset -M default home beginning-of-line
|
||||
$legacy_bind -s --preset -M default -k home beginning-of-line
|
||||
bind -s --preset -M insert end end-of-line
|
||||
$legacy_bind -s --preset -M insert -k end end-of-line
|
||||
bind -s --preset -M default end end-of-line
|
||||
$legacy_bind -s --preset -M default -k end end-of-line
|
||||
|
||||
# Vi moves the cursor back if, after deleting, it is at EOL.
|
||||
# To emulate that, move forward, then backward, which will be a NOP
|
||||
@@ -124,16 +119,12 @@ function fish_vi_key_bindings --description 'vi-like key bindings for fish'
|
||||
bind -s --preset -M default x delete-char 'set fish_cursor_end_mode exclusive' forward-single-char backward-char 'set fish_cursor_end_mode inclusive'
|
||||
bind -s --preset -M default X backward-delete-char
|
||||
bind -s --preset -M insert delete delete-char forward-single-char backward-char
|
||||
$legacy_bind -s --preset -M insert -k dc delete-char forward-single-char backward-char
|
||||
bind -s --preset -M default delete delete-char 'set fish_cursor_end_mode exclusive' forward-single-char backward-char 'set fish_cursor_end_mode inclusive'
|
||||
$legacy_bind -s --preset -M default -k dc delete-char 'set fish_cursor_end_mode exclusive' forward-single-char backward-char 'set fish_cursor_end_mode inclusive'
|
||||
|
||||
# Backspace deletes a char in insert mode, but not in normal/default mode.
|
||||
bind -s --preset -M insert backspace backward-delete-char
|
||||
bind -s --preset -M insert shift-backspace backward-delete-char
|
||||
$legacy_bind -s --preset -M insert -k backspace backward-delete-char
|
||||
bind -s --preset -M default backspace backward-char
|
||||
$legacy_bind -s --preset -M default -k backspace backward-char
|
||||
bind -s --preset -M insert ctrl-h backward-delete-char
|
||||
bind -s --preset -M default ctrl-h backward-char
|
||||
|
||||
@@ -282,7 +273,6 @@ function fish_vi_key_bindings --description 'vi-like key bindings for fish'
|
||||
# but this binding just move cursor backward, not delete the changes
|
||||
bind -s --preset -M replace backspace backward-char
|
||||
bind -s --preset -M replace shift-backspace backward-char
|
||||
$legacy_bind -s --preset -M replace -k backspace backward-char
|
||||
|
||||
#
|
||||
# visual mode
|
||||
|
||||
Reference in New Issue
Block a user