2024-04-12 10:19:32 +00:00
|
|
|
#RUN: %fish %s
|
2024-04-08 21:03:15 +00:00
|
|
|
#REQUIRES: command -v diff
|
|
|
|
|
|
|
|
set -l fish (status fish-path)
|
|
|
|
|
|
|
|
set -l tmpdir (mktemp -d)
|
|
|
|
for bindings in true fish_default_key_bindings fish_vi_key_bindings
|
|
|
|
$fish -c "
|
|
|
|
$bindings
|
|
|
|
bind > $tmpdir/old
|
|
|
|
bind --erase --all --preset
|
|
|
|
bind --erase --all
|
|
|
|
source $tmpdir/old
|
|
|
|
bind >$tmpdir/new
|
|
|
|
diff -u $tmpdir/{old,new}
|
|
|
|
"
|
|
|
|
end
|
|
|
|
echo >&2 bind output evaluation works
|
|
|
|
# CHECKERR: bind output evaluation works
|
|
|
|
|
2019-06-26 19:10:01 +00:00
|
|
|
# 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.
|
|
|
|
|
2023-12-30 00:26:39 +00:00
|
|
|
# Verify that an invalid bind mode is rejected.
|
2019-06-26 19:10:01 +00:00
|
|
|
bind -m 'bad bind mode' \cX true
|
2022-04-08 14:36:06 +00:00
|
|
|
# CHECKERR: bind: bad bind mode: invalid mode name. See `help identifiers`
|
2021-11-04 05:52:17 +00:00
|
|
|
|
2023-12-30 00:26:39 +00:00
|
|
|
# Verify that an invalid bind mode target is rejected.
|
2019-06-26 19:10:01 +00:00
|
|
|
bind -M bind-mode \cX true
|
2022-04-08 14:36:06 +00:00
|
|
|
# CHECKERR: bind: bind-mode: invalid mode name. See `help identifiers`
|
2019-06-26 19:10:01 +00:00
|
|
|
|
|
|
|
# This should succeed and result in a success, zero, status.
|
|
|
|
bind -M bind_mode \cX true
|
|
|
|
|
|
|
|
# Listing bindings
|
2024-04-08 15:35:24 +00:00
|
|
|
bind | string match -v '*\e\\[*' # Hide raw bindings.
|
|
|
|
bind --user --preset | string match -v '*\e\\[*'
|
2019-06-26 19:10:01 +00:00
|
|
|
# CHECK: bind --preset '' self-insert
|
2024-03-30 15:10:12 +00:00
|
|
|
# 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
|
2019-06-26 19:10:01 +00:00
|
|
|
# CHECK: bind --preset '' self-insert
|
2024-03-30 15:10:12 +00:00
|
|
|
# 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
|
2019-06-26 19:10:01 +00:00
|
|
|
|
|
|
|
# Preset only
|
2024-04-08 15:35:24 +00:00
|
|
|
bind --preset | string match -v '*\e\\[*'
|
2019-06-26 19:10:01 +00:00
|
|
|
# CHECK: bind --preset '' self-insert
|
2024-03-30 15:10:12 +00:00
|
|
|
# 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
|
2019-06-26 19:10:01 +00:00
|
|
|
|
|
|
|
# User only
|
2024-04-08 15:35:24 +00:00
|
|
|
bind --user | string match -v '*\e\\[*'
|
2024-03-30 15:10:12 +00:00
|
|
|
# CHECK: bind -M bind_mode ctrl-x true
|
2019-06-26 19:10:01 +00:00
|
|
|
|
|
|
|
# Adding bindings
|
2024-03-30 15:10:12 +00:00
|
|
|
bind tab 'echo banana'
|
2024-04-08 15:35:24 +00:00
|
|
|
bind | string match -v '*\e\\[*'
|
2019-06-26 19:10:01 +00:00
|
|
|
# CHECK: bind --preset '' self-insert
|
2024-03-30 15:10:12 +00:00
|
|
|
# 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'
|
2019-06-26 19:10:01 +00:00
|
|
|
|
2024-04-18 20:26:18 +00:00
|
|
|
# Legacy
|
|
|
|
bind \cx\cax 'echo foo'
|
|
|
|
bind \cx\cax
|
|
|
|
# CHECK: bind ctrl-x,ctrl-a,x 'echo foo'
|
|
|
|
bind \ef forward-word
|
|
|
|
bind \ef
|
|
|
|
# CHECK: bind alt-f forward-word
|
|
|
|
|
|
|
|
|
2019-06-26 19:10:01 +00:00
|
|
|
# Erasing bindings
|
2024-03-30 15:10:12 +00:00
|
|
|
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'
|
2019-06-26 19:10:01 +00:00
|
|
|
|
2024-04-02 15:47:56 +00:00
|
|
|
# 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'
|
|
|
|
|
2019-06-26 19:10:01 +00:00
|
|
|
exit 0
|