diff options
| author | littleblack111 <littleblack11111@gmail.com> | 2026-01-01 10:51:19 +0800 |
|---|---|---|
| committer | littleblack111 <littleblack11111@gmail.com> | 2026-01-01 10:51:19 +0800 |
| commit | f9600b3ac3b1dad83cb5874e757aca36d456861a (patch) | |
| tree | 076c5a61abdc286efefd731be15feaa830ca3bc2 | |
| parent | 2f4e23222c19dcb8d25f9e986904cd518dabe236 (diff) | |
fish: adapt upstream keybind api changes
| -rw-r--r-- | dot-config/fish/conf.d/binds.conf | 50 | ||||
| -rw-r--r-- | dot-config/fish/conf.d/funcs.fish | 6 |
2 files changed, 53 insertions, 3 deletions
diff --git a/dot-config/fish/conf.d/binds.conf b/dot-config/fish/conf.d/binds.conf new file mode 100644 index 00000000..7b6e5e6a --- /dev/null +++ b/dot-config/fish/conf.d/binds.conf @@ -0,0 +1,50 @@ +function toggle-sudo + set buf (commandline) + + if test -z "$buf" + set last (history | head -n1) + if test -z "$last" + commandline -r "sudo " + return + end + set buf $last + end + + if string match -rq '^\s*sudo(\s+|$)' -- $buf + set new (string replace -r '^\s*sudo\s*' '' -- $buf) + if test -z "$new" + commandline -r "" + return + end + commandline -r $new + else + commandline -r "sudo $buf" + end +end +function fish_user_key_bindings + for m in default insert + bind -M $m ctrl-f accept-autosuggestion + bind -M $m ctrl-backspace backward-kill-word + end + + for m in default insert normal + bind -M $m alt-left 'commandline -f cancel; cd -; commandline -f repaint' + bind -M $m alt-up 'commandline -f cancel; cd ..; commandline -f repaint' + bind -M $m ctrl-e toggle-sudo + bind -M $m ctrl-r history-pager + end + + bind -M normal U redo + + for m in default insert normal replace replace_one + bind --preset --erase -M $m ctrl-h + bind -M $m ctrl-h backward-char + bind --preset --erase -M $m ctrl-j + bind -M $m ctrl-j down-or-search + bind --preset --erase -M $m ctrl-k + bind -M $m ctrl-k up-or-search + # clear overrode + bind --preset --erase -M $m ctrl-l + bind -M $m ctrl-l forward-char + end +end diff --git a/dot-config/fish/conf.d/funcs.fish b/dot-config/fish/conf.d/funcs.fish index 5e3d01a3..593cb45a 100644 --- a/dot-config/fish/conf.d/funcs.fish +++ b/dot-config/fish/conf.d/funcs.fish @@ -56,9 +56,9 @@ function unzip ouch d --dir (string replace -r '\.[^./]+$' '' -- $argv[1]) $argv end -function path - echo (pwd)/$argv[1] -end +# function path +# echo (pwd)/$argv[1] +# end function vmake if test -e Makefile |
