fish shell
fish shell
現職の出来るエンジニアの人より、君はfish shellを利用すべきだねと言われました。
脳死YESマンなので、とりあえずzsh shell -> fish shellに変更しました。
その時の作業メモを残します。
fishとは?
Friendly interactive shellの略称だそうです。
今利用しているシェルがそもそも何かわからない場合は以下のコマンドを実行すると見ることができるらしいです。
echo $SHELL ->/usr/local/bin/fish
fishをインストールする(MacBook)
$ brew install fish $ fish -v
変更できるshellにfishを入れる
$ sudo -e /etc/shellsを実行したあと、aでインサートモード(編集モード)に入り、shell一覧の最後にfishのパス/usr/local/bin/fishを追加します。
1 # List of acceptable shells for chpass(1). 1 # Ftpd will not allow users to connect who are not using 2 # one of these shells. 3 4 /bin/bash 5 /bin/csh 6 /bin/ksh 7 /bin/sh 8 /bin/tcsh 9 /bin/zsh 10 /usr/local/bin/fish <=== 追加
デフォルトshellをfishにする
chsh -s /usr/local/bin/fish
fishを入れるメリット
最初から良い感じ
zshは高機能ですが、自分でカスタマイズしないと良い感じにならないです。
ただ、fishは自分で設定しなくても最初から良い感じに機能とかがデフォでついてます。
履歴から自動で補完候補を表示
fishでは自動で補完候補を表示してくれます。
カラフルでわかりやすい
fishはデフォルトでカラフルな見た目をしているので、分かりやすいです。
bashのデフォルトは色が少なく分かりにくい....
設定がGUIで分かりやすい
基本的には~/.config/fish/config.fishに書いていきます。
ただ、以下のコマンドを打つとGUIで設定をいじる事が出来ます。
(あとブラウザで変更した設定は~/.config/fish/config.fishではなく~/.config/fish/fishd.
fish_config
上記のコマンド打つとこんな画面が表示される。(個人的にはLavaがおすすめ)
prompt タブでSet Promptを押すと、.config/fish/functions/fish_prompt.fishが生成される。
ブランチ名の表示をさせるように改造しよう。
.config/fish/functions/fish_prompt.fish
function fish_prompt echo -n (set_color cyan)(prompt_pwd) (set_color green)'❯' # Git set last_status $status printf '%s ' (__fish_git_prompt) set_color normal end
反映
source .config/fish/functions/fish_prompt.fish
これでブランチ名称が表示されるようになりました。
Fisher
Fisherはfishのプラグインの管理ツールです。
インストール ↓
curl https://git.io/fisher --create-dirs -sLo ~/.config/fish/functions/fisher.fish
GitHub - jorgebucaran/fisher: A plugin manager for Fish.
自分的に最低限必要だなと思うpluginをインストール
ちなみに何のプラグインいれたか忘れた時は以下のコマンドを打つとインストール済みプラグインを表示します
fisher ls
plugin-peco
pecoでhistoryをインクリメンタルに検索できるやつ。
$ fisher add oh-my-fish/plugin-peco
~/.config/fish/config.fish
function fish_user_key_bindings bind \cr 'peco_select_history (commandline -b)' end
fish-peco_select_ghq_repository
$ fisher add yoshiori/fish-peco_select_ghq_repository
~/.config/fish/config.fish
function fish_user_key_bindings bind \c] peco_select_ghq_repository end