LoginSignup
5
1

More than 5 years have passed since last update.

zsh-syntax-highlighting が使用できない場合

Last updated at Posted at 2019-02-26

zsh-synyax-highlighting を導入しようとしたら、ちょっとだけ詰まった話。

zsh-synyax-highlightingとは、その名の通り、ターミナルコマンドに色をつけて見やすくしてくれるプラグインだ。

image.png

こんな感じ。cdllコマンドが緑色になっているのが確認できるだろう。

基本的に公式ページのhow to install を見てその通りに進めて行けばOKです。
https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/INSTALL.md

私はoh-my-zshを既に導入していたので、↓の方法でインストール

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

そして、~/.zshrcファイルを書き換えていくのだが、ここで事件発生。

vim ~/.zshrcで当該ファイルを開き、編集!

plugins=( [plugins...] zsh-syntax-highlighting)

ここで事件発生。
こいつをコピペしたらzshが動かなくなってしまったのだ。bashの画面に戻ってしまってものすごく焦ったのだが、原因は[plugins...]。これ、他のプラグインが書かれていますよー、という親切なお知らせ。

何もいじっていなければ66行目あたりに

~/.zshrc
plugins=(git)

と書かれているはずなので、こいつを

~/.zshrc
plugins=(git zsh-syntax-highlighting)

と書き換えてあげればいいだけの話だったのだ。

保存して source ~/.zshrc すると、無事にハイライトされていた。

めでたしめでたし。

参考:
https://medium.freecodecamp.org/jazz-up-your-zsh-terminal-in-seven-steps-a-visual-guide-e81a8fd59a38

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