zsh ではできるグローバルエイリアス。
これを fish でもできるようにしたプラグインが
ryotako/fish-global-abbreviation
設定の方法は、 fishでグローバルエイリアスっぽいもの - Qiita を見るといい感じ。
ただ、この設定だと、 Space とかでは展開されるんだけど、 zsh みたいに Enter で展開することができなかった。
なので、以下の設定を fish_user_key_bindings.fish に実施した。
bash
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
function fish_user_key_bindings
# Additional bind for fish_vi_key_bindings.
bind -M insert \cf accept-autosuggestion
bind -M insert \cn down-or-search
bind -M insert \cp up-or-search
# global abbreviation.
bind -M insert ' ' '__gabbr_expand; commandline -i " "'
bind -M insert ';' '__gabbr_expand; commandline -i ";"'
bind -M insert '>' '__gabbr_expand; commandline -i ">"'
bind -M insert '<' '__gabbr_expand; commandline -i "<"'
bind -M insert '(' '__gabbr_expand; commandline -i "("'
bind -M insert ')' '__gabbr_expand; commandline -i ")"'
bind -M insert \cj '__gabbr_expand; commandline -f execute'
bind -M insert \cm '__gabbr_expand; commandline -f execute'
bind -M insert \r '__gabbr_expand; commandline -f execute'
end重要なのは、一番下3行。
__gabbr_expand だけじゃなくて、 commandline -f execute を追加するのいいみたい。