
永く zsh を愛用している割に、環境設定は割とすぐに忘れがちです。
最近 MBP を新調したときに zsh のプラグインマネージャを oh-my-zsh から zplug に変更しました。それももう忘れつつあるので、思い出しながらメモっておきます。
zsh のインストール
mac の場合
mac の場合は、macOS Catalina から zsh がデフォルトになったらしいので、インストールは不要。
Catalina以前は、
$ xcode-select --install
$ brew install zsh
windowsの場合
wsl2 でlinux環境(ここでは ubuntu)を用意した後、下記の通りubuntuにzshをインストールする
ubuntu の場合
$ sudo apt-get install zsh
シェルの変更
chsh コマンドで変更する。$(which zsh) はzshへのパス。
$ chsh -s $(which zsh)
zplug のインストール
.zshrc の設定
自分好み設定を.zshrc に記述する。以下は僕の設定。ほぼデフォルト設定で#zplug以降が追加したzplugの設定
~/.zshrc
autoload -Uz promptinit
promptinit
setopt histignorealldups sharehistory
bindkey -v
HISTSIZE=1000
SAVEHIST=1000
HISTFILE=~/.zsh_history
autoload -Uz compinit
compinit
zstyle ':completion:*' auto-description 'specify: %d'
zstyle ':completion:*' completer _expand _complete _correct _approximate
zstyle ':completion:*' format 'Completing %d'
zstyle ':completion:*' group-name ''
zstyle ':completion:*' menu select=2
eval "$(dircolors -b)"
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
zstyle ':completion:*' list-colors ''
zstyle ':completion:*' list-prompt %SAt %p: Hit TAB for more, or the character to insert%s
zstyle ':completion:*' matcher-list '' 'm:{a-z}={A-Z}' 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=* l:|=*'
zstyle ':completion:*' menu select=long
zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s
zstyle ':completion:*' use-compctl false
zstyle ':completion:*' verbose true
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31'
zstyle ':completion:*:kill:*' command 'ps -u $USER -o pid,%cpu,tty,cputime,cmd'
source ~/.zplug/init.zsh
zplug "mafredri/zsh-async"
zplug "themes/wedisagree", from:oh-my-zsh, as:theme
zplug "zsh-users/zsh-syntax-highlighting"
zplug "chrissicool/zsh-256color"
zplug "zsh-users/zsh-history-substring-search"
zplug "zsh-users/zsh-autosuggestions"
zplug "zsh-users/zsh-completions"
zplug "mrowa44/emojify", as:command
if ! zplug check --verbose; then
printf 'Install? [y/N]: '
if read -q; then
echo; zplug install
fi
fi
zplug load --verbose
source コマンドで .zshrc を反映させる
$ source .zshrc
未インストールのプラグインがある場合、インストールするかどうか聞かれるので、y を押してインストールする
ゴール
