Bala's Blog

Z shell

August 12 2018
236 words, ~2 min. read
linux,  freebsd,  shell,  zsh 
  1. Install as root # pkg install zsh
  2. Make zsh as default shell using $ chsh -s zsh
  3. Install oh my zsh $ sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
  4. Install Antigen, plugin manager for zsh # pkg install zsh-antigen. Also, source /usr/local/share/zsh-antigen/antigen.zsh in ~.zshrc.
  5. Install plugins, themes, etc.

To install zsh-syntax-highlighting and zsh-autosuggestions plugins,

$ git clone https://github.com/zsh-users/zsh-syntax-highlighting ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
$ git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

Also, ensure to enable these plugins in ~/.zshrc

plugins=(
    git
    zsh-syntax-highlighting
    zsh-autosuggestions
)

To install powerlevel9k theme,

$ sudo pkg install powerline-fonts
$ git clone https://github.com/bhilburn/powerlevel9k ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/themes/powerlevel9k

And, ensure to set the theme in ~/.zshrc.

ZSH_THEME="powerlevel9k/powerlevel9k"

Notes

File name completions
similar behaviour as of bash
Directory name completions
e.g. type cd and press TAB to loop through the directories available
Path expansions
e.g. type cd /u/lo/b and press TAB to expand to /usr/local/bin
Path replacements
e.g. if already in /usr/local/bin directory, type cd bin share to switch to /usr/local/share directory
Command completions
e.g. within a git repository, type git st and press TAB to see possible completions like stash, status
Right prompt
e.g. export RPS1=%d to see directory names on the right side of the prompt
Normal aliases
e.g. alias ec="emacsclient -tc"
Global aliases
e.g. alias -g gi="grep -i"
Open-with aliase
e.g. alias -s py=ec
Environment edit
e.g. vared PATH
Function Hooks
please refer this page for more details

References