Ikkyu's Tech Blog

技術系に関するブログです。

fish shellを使用してみる

職場の人がfishというshellを使用していて、ペアプロとかしていて使いやすそうだなって思ってました。Mac Book Proをクリーンインストールしたついでに使用してみることにしました。

fishshell.com

Homebrewをインストール

$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

fishをインストール

$ brew install fish

パスを確認します。

$ which fish
/usr/local/bin/fish

ログインshellを変更

$ chsh -s /usr/local/bin/fish
chsh: /usr/local/bin/fish: non-standard shell

エラーが出ちゃいました。。😇
ので調査

qiita.com

なるほど。新たにパスを/etc/shellsに追加する必要があると...

$ sudo vim /etc/shells

末尾に/usr/local/bin/fishを追記します。

保存したら確認してみます。

$ cat /etc/shells
# List of acceptable shells for chpass(1).
# Ftpd will not allow users to connect who are not using
# one of these shells.

/bin/bash
/bin/csh
/bin/ksh
/bin/sh
/bin/tcsh
/bin/zsh
/usr/local/bin/fish
$ chsh -s /usr/local/bin/fish

ターミナルを再度開き直します。

もうなんか変わってますね!!

$ echo $SHELL
/usr/local/bin/fish

OK!!!デフォルトでいい感じになっています。

設定はfish_configと入力するとブラウザ上で設定が行えます。

設定

パスの設定などは、config/fish/config.fishに記入します。

なければ作成します。

touch ~/.config/fish/config.fish

例: ディレクトリの色を変更する

echo 'export LSCOLORS=gxfxcxdxbxegedabagacad' >> ~/.config/fish/config.fish

タブ補完を追加

こちらを参考にしました。

blog.lorentzca.me

公式で色々提供してくれてるみたいですね!さすが!!!👌

$ mkdir ~/.config/fish/completions // ディレクトリがない場合は作成します。
$ curl https://raw.githubusercontent.com/fish-shell/fish-shell/master/share/completions/git.fish > ~/.config/fish/completions/git.fish

github.com