mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-28 13:53:10 +00:00
f61ef2c63d
If a binding was input starting with "\e", it's usually a raw control sequence. Today we display the canonical version like: bind --preset alt-\[,1,\;,5,C foo even if the input is bind --preset \e\[1\;5C foo Make it look like the input again. This looks more familiar and less surprising (especially since we canonicalize CSI to "alt-["). Except that we use the \x01 representation instead of \ca because the "control" part can be confusing. We're inside an escape sequence so it seems highly unlikely that an ASCII control character actually comes from the user holding the control key. The downside is that this hides the canonical version; it might be surprising that a raw-escape-sequence binding can be erased using the new syntax and vice versa.
123 lines
4.3 KiB
Fish
123 lines
4.3 KiB
Fish
#RUN: %fish %s | %filter-ctrlseqs
|
|
# Test various `bind` command invocations. This is meant to verify that
|
|
# invalid flags, mode names, etc. are caught as well as to verify that valid
|
|
# ones are allowed.
|
|
|
|
# Verify that an invalid bind mode is rejected.
|
|
bind -m 'bad bind mode' \cX true
|
|
# CHECKERR: bind: bad bind mode: invalid mode name. See `help identifiers`
|
|
|
|
# Verify that an invalid bind mode target is rejected.
|
|
bind -M bind-mode \cX true
|
|
# CHECKERR: bind: bind-mode: invalid mode name. See `help identifiers`
|
|
|
|
# This should succeed and result in a success, zero, status.
|
|
bind -M bind_mode \cX true
|
|
|
|
# Listing bindings
|
|
bind | string match -v '*\e\\[*' # Hide raw bindings.
|
|
bind --user --preset | string match -v '*\e\\[*'
|
|
# CHECK: bind --preset '' self-insert
|
|
# CHECK: bind --preset enter execute
|
|
# CHECK: bind --preset tab complete
|
|
# CHECK: bind --preset ctrl-c cancel-commandline
|
|
# CHECK: bind --preset ctrl-d exit
|
|
# CHECK: bind --preset ctrl-e bind
|
|
# CHECK: bind --preset ctrl-s pager-toggle-search
|
|
# CHECK: bind --preset ctrl-u backward-kill-line
|
|
# CHECK: bind --preset backspace backward-delete-char
|
|
# CHECK: bind --preset up up-line
|
|
# CHECK: bind --preset down down-line
|
|
# CHECK: bind --preset right forward-char
|
|
# CHECK: bind --preset left backward-char
|
|
# CHECK: bind --preset ctrl-p up-line
|
|
# CHECK: bind --preset ctrl-n down-line
|
|
# CHECK: bind --preset ctrl-b backward-char
|
|
# CHECK: bind --preset ctrl-f forward-char
|
|
# CHECK: bind -M bind_mode ctrl-x true
|
|
# CHECK: bind --preset '' self-insert
|
|
# CHECK: bind --preset enter execute
|
|
# CHECK: bind --preset tab complete
|
|
# CHECK: bind --preset ctrl-c cancel-commandline
|
|
# CHECK: bind --preset ctrl-d exit
|
|
# CHECK: bind --preset ctrl-e bind
|
|
# CHECK: bind --preset ctrl-s pager-toggle-search
|
|
# CHECK: bind --preset ctrl-u backward-kill-line
|
|
# CHECK: bind --preset backspace backward-delete-char
|
|
# CHECK: bind --preset up up-line
|
|
# CHECK: bind --preset down down-line
|
|
# CHECK: bind --preset right forward-char
|
|
# CHECK: bind --preset left backward-char
|
|
# CHECK: bind --preset ctrl-p up-line
|
|
# CHECK: bind --preset ctrl-n down-line
|
|
# CHECK: bind --preset ctrl-b backward-char
|
|
# CHECK: bind --preset ctrl-f forward-char
|
|
# CHECK: bind -M bind_mode ctrl-x true
|
|
|
|
# Preset only
|
|
bind --preset | string match -v '*\e\\[*'
|
|
# CHECK: bind --preset '' self-insert
|
|
# CHECK: bind --preset enter execute
|
|
# CHECK: bind --preset tab complete
|
|
# CHECK: bind --preset ctrl-c cancel-commandline
|
|
# CHECK: bind --preset ctrl-d exit
|
|
# CHECK: bind --preset ctrl-e bind
|
|
# CHECK: bind --preset ctrl-s pager-toggle-search
|
|
# CHECK: bind --preset ctrl-u backward-kill-line
|
|
# CHECK: bind --preset backspace backward-delete-char
|
|
# CHECK: bind --preset up up-line
|
|
# CHECK: bind --preset down down-line
|
|
# CHECK: bind --preset right forward-char
|
|
# CHECK: bind --preset left backward-char
|
|
# CHECK: bind --preset ctrl-p up-line
|
|
# CHECK: bind --preset ctrl-n down-line
|
|
# CHECK: bind --preset ctrl-b backward-char
|
|
# CHECK: bind --preset ctrl-f forward-char
|
|
|
|
# User only
|
|
bind --user | string match -v '*\e\\[*'
|
|
# CHECK: bind -M bind_mode ctrl-x true
|
|
|
|
# Adding bindings
|
|
bind tab 'echo banana'
|
|
bind | string match -v '*\e\\[*'
|
|
# CHECK: bind --preset '' self-insert
|
|
# CHECK: bind --preset enter execute
|
|
# CHECK: bind --preset tab complete
|
|
# CHECK: bind --preset ctrl-c cancel-commandline
|
|
# CHECK: bind --preset ctrl-d exit
|
|
# CHECK: bind --preset ctrl-e bind
|
|
# CHECK: bind --preset ctrl-s pager-toggle-search
|
|
# CHECK: bind --preset ctrl-u backward-kill-line
|
|
# CHECK: bind --preset backspace backward-delete-char
|
|
# CHECK: bind --preset up up-line
|
|
# CHECK: bind --preset down down-line
|
|
# CHECK: bind --preset right forward-char
|
|
# CHECK: bind --preset left backward-char
|
|
# CHECK: bind --preset ctrl-p up-line
|
|
# CHECK: bind --preset ctrl-n down-line
|
|
# CHECK: bind --preset ctrl-b backward-char
|
|
# CHECK: bind --preset ctrl-f forward-char
|
|
# CHECK: bind -M bind_mode ctrl-x true
|
|
# CHECK: bind tab 'echo banana'
|
|
|
|
# Erasing bindings
|
|
bind --erase tab
|
|
bind tab
|
|
bind tab 'echo wurst'
|
|
# CHECK: bind --preset tab complete
|
|
bind --erase --user --preset tab
|
|
bind tab
|
|
# CHECKERR: bind: No binding found for key 'tab'
|
|
|
|
bind ctrl-\b
|
|
# CHECKERR: bind: Cannot add control modifier to control character 'ctrl-h'
|
|
|
|
# Either Return or ctrl-m.
|
|
bind \r
|
|
# CHECK: bind --preset enter execute
|
|
# Never Return, probably always ctrl-j.
|
|
bind \n 2>&1
|
|
# CHECK: bind: No binding found for key 'ctrl-j'
|
|
|
|
exit 0
|