LoginSignup
2
0

More than 3 years have passed since last update.

fish shellで空enterを入力したらlsを実行するようにする

Posted at

fish shellで空enterを入力したらlsを実行するようにする

ちょっとした効率化で"空enterでlsを実行する"をよいという話を聞くのでfishで実装しようとした。
(zshだとプラグインであるみたい)

できたもの

function enter_ls
    set -l cmd (commandline)
    if test -z "$cmd"
        echo 
        ls
    end
    commandline -f execute
end 

function fish_user_key_binding
    bind \r enter_ls
end

これを~/.config/fish/function/下に置くと\r(enter)がenter_lsの実行になる。

最初は function enter_ls --on-event fish_postexecで書こうと考えたが、バージョンが上がって空コマンドだとこのイベントが発行されないようになっていた

個人的にenterにバインドするのはあまり気持ちよくない(他のenterで実行されるものと被ると面倒)けどもイベントが無いならこれしか実現法は無いような気がする。

参考

2
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
2
0