zsh

zsh #

Terminal #

Set zsh as a default shell #

Check the default shell

$ echo $SHELL
/bin/bash

Check a list of available shells

$ cat /etc/shells
/bin/bash
/bin/csh
/bin/ksh
/bin/sh
/bin/tcsh
/bin/zsh

Change the default shell from bash to zsh

$ chsh -s /bin/zsh

Copy configurations

$ cat ~/.bashrc >> ~/.zshrc
$ cat ~/.bash_profile >> ~/.zshrc

Please rewrite the configuration for bash to the one for zsh

Set prefix match #

vi ~/.zshrc

Please write the following and save the file.

# Prefix Match
autoload -Uz history-search-end
zle -N history-beginning-search-backward-end history-search-end
zle -N history-beginning-search-forward-end history-search-end
bindkey "^[[A" history-beginning-search-backward-end
bindkey "^[[B" history-beginning-search-forward-end

Apply the change.

% source ~/.zshrc

Autosuggestions #

Install zsh-autosuggestions

brew install zsh-autosuggestions
echo `source /usr/local/share/zsh-autosuggestions/zsh-autosuggestions.zsh` >> ~/.zshrc
exec zsh

Visual Studio Code #

Set zsh as a default shell #

  1. Cmd + Shift + P
  2. Select Terminal: Select Default Profile
  3. Select zsh zsh -l