MacのOSをCatalinaに変更した際、デフォルトのShellをZshに変更しました。
このタイミングでOh My Zshで設定を変更したのでブログに残しておきます。
Oh my zshのインストール
curlが使えたのでこちらのコマンドでインストールしました。
curlが無い場合は、wgetやManualでのインストール方法がgithubに記載されています。
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
.zshrcを修正
ここではThemeの設定、Window title、Aliasの設定をしています。
Oh my zshにはデフォルトで多くのThemeがありますが、agnosterを使っています。
~/.zshrc
#ZSH_THEME="robbyrussell" ZSH_THEME="agnoster" # Uncomment the following line to disable auto-setting terminal title. DISABLE_AUTO_TITLE="true" function precmd() { local wname=`pwd | sed -e "s|$HOME|~|"` #Set current directory as "~" local tname=`pwd | sed -e "s|$HOME|~|"` echo -ne "\033]2;$wname\007" # window title echo -ne "\033]1;$tname\007" # tab title } # Example aliases # alias zshconfig="mate ~/.zshrc" # alias ohmyzsh="mate ~/.oh-my-zsh" alias ls='ls -G' alias ll='ls -lG' alias la='ls -laG'
Themeの設定変更
Shellのプロンプト表示を変更しています。デフォルトだと長いのでCurrent Directoryを表示するようにしています。
~/.oh-my-zsh/themes/agnoster.zsh-theme
# Context: user@hostname (who am I and where am I) prompt_context() { if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then # prompt_segment black default "%(!.%{%F{yellow}%}.)%n@%m" fi } # Dir: current working directory prompt_dir() { #prompt_segment blue $CURRENT_FG '%1~' #prompt_segment blue $CURRENT_FG '%~' prompt_segment blue $CURRENT_FG '%c' #Only current dir }
Powerline fontのインストール
Powerline fontをインストールしないとgitのリポジトリ情報が化けてしまいますのでこちらをインストールしています。
# clone git clone https://github.com/powerline/fonts.git --depth=1 # install cd fonts ./install.sh # clean-up a bit cd .. rm -rf fonts
TerminalのFont設定変更
インストールしたフォントを使うようにTerminalも設定を変更します。
参考URL:
ターミナルのウィンドウとタブに自動的に名前をつける - Qiita