1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

fishからzshに戻す

Posted at

長らく開発でfishシェルを利用してきました。
恐ろしく軽量で、かつインストールするだけで強力な補完機能が利用できる。そしてカスタマイズも楽ということでとても好きなのですが、多くの方の指摘通り、文法が特殊で扱いづらさがありました。
そこで、fishとお別れしつつ、fishの補完機能などを利用できるzshを目指して移行していきます。その備忘録です。

warpなど、ai + シェルというツールも増えてきている昨今、あまりひつようないのかもしれないd

※macOSに限った記事です。

1. fishを削除する。

潔くuninstallしていきましょう。
homebrew経由でインストールしたので、brewコマンドを利用します。

brew uninstall fish

以下のように出力されるので、その通りに削除していきます。

The following fish configuration files have not been removed!
If desired, remove them manually with `rm -rf`:
  /opt/homebrew/etc/fish
  /opt/homebrew/etc/fish/config.fish
rm -rf /opt/homebrew/etc/fish /opt/homebrew/etc/fish/config.fish

configファイルは消えないので、手動で削除します。

rm -rf ~/.config/fish
# 確認
ls -la  ~/.config/fish
ls: /Users/<user-name>/.config/fish: No such file or directory
which fish
fish not found
fish
zsh: command not found: fish

これで削除完了です。

2. zshのカスタマイズ

oh my zshをインストール

oh-my-zshを利用している方が多く、プラグインも多そうだったのでこちらをインストールしていきます。

readme記載のcurlコマンドでインストールします。
※実際にインストールする際は上記githubをご覧いただくのが確実です。

sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

この時、新しく~/.zshrcファイルが作成されるとともに、既存の~/.zshrc~/.zshrc.pre-oh-my-zshに変更されます。

新しいファイルにコピーする or 元のファイルから新しいファイルを読み込む形にするか迷いましたが、fishシェルへの切り替えが早く大した量の記述でもなかったため、zshrc.pre-oh-my-zshの内容を新しいファイルの最上部にコピペしました。

ほか機能pluginをインストール

zsh-syntax-highlightingとzsh-autosuggestionsを入れます。
前者はコマンドを色付けしてくれ、後者が自動補完です。

git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

その後、~/.zshrcのpluginに以下を書き込みます。
(gitはデフォルトで入っているようです。)

plugins=(
	git
	zsh-syntax-highlighting
	zsh-autosuggestions
)

念の為適用コマンド

source ~/.zshrc

image.png

補完や色が効くようになりました。

以上です。
うーん、やっぱりfishシェルのシンプルさが良くて戻すかも、、なんて思ったり。
なれの問題でしょうか。

参考記事

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?