ZshとPreztoでターミナルをカスタマイズする
zshをカスタマイズしたときの備忘録です。
Preztoのインストール
- zshの起動
$zsh
- zshのインストール
$ brew install zsh
- Preztoの取得
$ git clone --recursive https://github.com/sorin-ionescu/prezto.git "${ZDOTDIR:-$HOME}/.zprezto"
`
- 設定ファイルの作成
$ setopt EXTENDED_GLOB
$ for rcfile in "${ZDOTDIR:-$HOME}"/.zprezto/runcoms/^README.md(.N); do ln -s "$rcfile" "${ZDOTDIR:-$HOME}/.${rcfile:t}" done
デフォルトをzshにする
$ chsh -s /bin/zsh
アップデートする
$ cd $ZPREZTODIR
$ git pull
$ git submodule update --init --recursive
Preztoのテーマを確認する
$ prompt -p
~/.zpreztorcを編集する(themaを変更する)
zstyle ':prezto:module:prompt' theme 'テーマ名'
- 今回はこれにする
zstyle ':prezto:module:prompt' theme 'fire'
zshからログアウトしてログインすると反映される
文字の色がわかりにくいので変更する
.zshrc
に以下を追加する
# Char Color export CLICOLOR=1 export LSCOLORS=DxGxcxdxCxegedabagacad
- 設定後のzsh
コマンドの補完のために
- Macの場合
$ brew install zsh-completions
- .zshrcに追記する
# zsh_completions fpath=(/usr/local/share/zsh-completions $fpath)
自分の .zshrc(Mac) ※ 適宜更新
# Source Prezto. if [[ -s "${ZDOTDIR:-$HOME}/.zprezto/init.zsh" ]]; then source "${ZDOTDIR:-$HOME}/.zprezto/init.zsh" fi # Color export CLICOLOR=1 export LSCOLORS=DxGxcxdxCxegedabagacad # zsh_completions fpath=(/usr/local/share/zsh-completions $fpath) # Python export PYENV_ROOT="$HOME/.pyenv" eval "$(pyenv init -)" # git completion fpath=(~/.zsh/completion $fpath) autoload -U compinit compinit -u # Customize to your needs... # for peco (brew install peco) function select-history() { local tac if which tac > /dev/null; then tac="tac" else tac="tail -r" fi BUFFER=$(fc -l -n 1 | eval $tac | peco --query "$LBUFFER") CURSOR=$#BUFFER zle -R -c } zle -N select-history bindkey '^r' select-history alias ls="ls -G