LoginSignup
0
0

More than 3 years have passed since last update.

macOS Catalina からデフォルトになった zsh 環境をシンプルに改善する

Last updated at Posted at 2020-01-12

今までずっと bash 一択だったんですが、macOS のデフォルトシェルが Catalinazsh に変更されたのを受けて Apple 信者の僕は早速 zsh ユーザーに転生しました

zsh は高機能なだけに設定が複雑になってしまう印象があったので嫌だったんですが、いろいろ試してみたらかなりシンプルで理想的な環境が構築できたので、晒します

https://github.com/hysh8392/dotfiles/

TL;DR

プロンプト
スクリーンショット 2020-01-12 12.21.50.png

スクリーンショット 2020-01-12 12.23.47.png

タブ補完
スクリーンショット 2020-01-12 12.22.33.png

スクリーンショット 2020-01-12 12.26.04.png

.zshrc

autoload -Uz colors && colors
autoload -Uz compinit && compinit
autoload -Uz vcs_info

PROMPT='%F{green}%n@%m:%f%F{blue}%~%f
%# '
PROMPT2="> "

setopt prompt_subst
zstyle ':vcs_info:*' check-for-changes true
zstyle ':vcs_info:*' stagedstr "%F{yellow}!"
zstyle ':vcs_info:*' unstagedstr "%F{red}*"
zstyle ':vcs_info:*' formats "%F{green}%c%u[%b]%f"
zstyle ':vcs_info:*' actionformats '[%b|%a]'
precmd () { vcs_info }
RPROMPT=$RPROMPT'${vcs_info_msg_0_}'

手順とか

クリーンインストールしたばかりの Catalina 環境を汚したくない方は、一旦 Docker で試しましょう

% docker run --interactive --tty --rm alpine:3.11 ash

とりあえず最低限必要なパッケージをインストールします

# apk add curl git zsh zsh-vcs

github に公開してる .zshrc をダウンロードします(もちろん直接 vi で書いてもいいです)

# cd ~/ && curl https://raw.githubusercontent.com/hysh8392/dotfiles/master/.zshrc --remote-name

zsh に切り替えて適当な git リポジトリを取得していろいろ試します
スクリーンショット 2020-01-12 14.43.01.png
いい感じですね!

凝りだしたらキリがないのでこれぐらいにしときましょう笑

気に入ったら↑の .zshrc をコピペして mac 環境に適用しちゃってくださいw

参考記事
- zshプロンプトのカスタマイズ
- zsh の vcs_info に独自の処理を追加して stash 数とか push していない件数とか何でも表示する

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