fork/fish-shell

git clone https://git.julia.blue/fork/fish-shell

Peter AmmonMerge branch 'ahti-revert-alt-behaviour'cb1de5aab

master
2.4 KiB67 linesraw
1function fish_default_key_bindings -d "emacs-like key binds"
2    if contains -- -h $argv
3        or contains -- --help $argv
4        echo "Sorry but this function doesn't support -h or --help"
5        return 1
6    end
7
8    if not set -q argv[1]
9        bind --erase --all --preset # clear earlier bindings, if any
10        if test "$fish_key_bindings" != fish_default_key_bindings
11            __fish_change_key_bindings fish_default_key_bindings
12            set fish_bind_mode default
13        end
14    end
15
16    # These are shell-specific bindings that we share with vi mode.
17    eval "$(__fish_shared_key_bindings)" $argv
18    or return # protect against invalid $argv
19
20    bind --preset $argv right forward-char
21    bind --preset $argv left backward-char
22
23    bind --preset $argv delete delete-char
24    bind --preset $argv backspace backward-delete-char
25    bind --preset $argv shift-backspace backward-delete-char
26
27    bind --preset $argv home beginning-of-line
28    bind --preset $argv end end-of-line
29
30    bind --preset $argv ctrl-a beginning-of-line
31    bind --preset $argv ctrl-e end-of-line
32    bind --preset $argv ctrl-h backward-delete-char
33    bind --preset $argv ctrl-p up-or-search
34    bind --preset $argv ctrl-n down-or-search
35    bind --preset $argv ctrl-f forward-char
36    bind --preset $argv ctrl-b backward-char
37    bind --preset $argv ctrl-t transpose-chars
38    bind --preset $argv ctrl-g cancel
39    bind --preset $argv ctrl-/ undo
40    bind --preset $argv ctrl-_ undo # XTerm idiosyncracy, can get rid of this once we go full CSI u
41    bind --preset $argv ctrl-z undo
42    bind --preset $argv ctrl-shift-z redo
43    bind --preset $argv alt-/ redo
44    bind --preset $argv alt-t transpose-words
45    bind --preset $argv alt-u upcase-word
46
47    bind --preset $argv alt-c capitalize-word
48
49    bind --preset $argv alt-backspace backward-kill-word
50    bind --preset $argv ctrl-alt-h backward-kill-word
51    bind --preset $argv ctrl-backspace backward-kill-token
52    bind --preset $argv alt-delete kill-word
53    bind --preset $argv ctrl-delete kill-token
54
55    bind --preset $argv alt-\< beginning-of-buffer
56    bind --preset $argv alt-\> end-of-buffer
57
58    bind --preset $argv ctrl-r history-pager
59
60    # TODO(term-workaround)
61    switch "$TERM"
62        case xterm-256color
63            # Microsoft's conemu uses xterm-256color plus
64            # the following to tell a console to paste:
65            bind --preset $argv \e\x20ep fish_clipboard_paste
66    end
67end