LoginSignup
0
0

More than 3 years have passed since last update.

fish shell にコマンドラインスタック機能を付ける

Last updated at Posted at 2021-04-23

コマンドラインスタック機能(push-line)

コマンドラインスタック機能とは、コマンドを打っている途中に他のコマンドを先に実行すべきだと気付いた時、一時的に入力を中断できる機能のこと。(他のコマンドを実行し終えたら入力を再開できる)

標準機能かと思ったのだがなかった。
そこでfisher コマンドを使って次のプラグインをインストール。

fisher install ccyip/push-line.fish

これでAlt-q で入力中のコマンドを後回しにできる。(やってみて)

vi keybindings でも同じことをやるには?

bind -M insert \eq push_line

と入力すればよい。Alt-q で利用できる。(\e とはAlt のことで、\eq でAlt-q という意味)

設定をconfig.fish に保存する

こちらの設定と合わせてconfig.fish に保存する方法です。

~/.config/fish/config.fish に次のように書いてください。

function fish_user_key_bindings
  bind -M insert \cf forward-char
  bind -M insert \eq push_line
end

MEMO fish_user_key_bindings?

なお、function fish_user_key_bindings に書く理由は以下の通りです。

~/.config/fish/config.fish 内に
直接書かれた bind コマンドは
有効になりません。

なぜなら、
デフォルトのキーバインドが設定される前に
config.fish が読み込まれるからです。

自分用のキーバインドを保存するためには、
bind コマンドを
fish_user_key_bindings オートロード関数 内に
書いてください。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0