GyaaniGuy

- self made šŸ’» šŸ˜Ž

Worlds greatest and simplest guide for ZSH the best shell on the planet

Why Zsh ?

Internet explorer was shit. But it was shit that got buried. Bash is not shit. But if it doesn’t get buried soon it will soon start smelling, behaving and be’ing shit

Zsh has much much saner defaults. Sooo much better completion. Very cool, very easy to setup plugins to take it to the next level.

This is The world’s greatest and simplest guide to setup the most kickass shell

Quick Setup:

Install Ā 

apt install zsh 
zsh > wizard start > press 2 to exit.
  1. install plugins:
# install plugin manager  
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" Ā   
# some plugins  
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions  
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $ZSH_CUSTOM/plugins/zsh-syntax-highlighting  
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf  
~/.fzf/install  #press y for everything  
# fzf zsh integration plugin
git clone https://github.com/Aloxaf/fzf-tab ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/fzf-tab  

  1. Configuration: Edit ~/.zshrc
#Enable plugins. Modify plugins lineĀ as 
plugins=(fzf-tab zsh-autosuggestions git dirhistory zsh-syntax-highlighting )  
# Running ~/.fzf/install should have added below line automatically:
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh   # Add if not present

For reference: My ~/.zshrc

export ZSH="$HOME/.oh-my-zsh"  
#ZSH_THEME="powerlevel10k/powerlevel10k"  
plugins=(fzf-tab z zsh-autosuggestions git dirhistory history zsh-syntax-highlighting )  
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh  
source $ZSH/oh-my-zsh.sh  
  
# some modifications. can ignore maybe  
autoload -U compinit && compinit  
zstyle ':completion:*' menu select    
# history sanity options. 
setopt HIST\_FIND\_NO_DUPS  
setopt HIST\_SAVE\_NO_DUPS 

That should be it!

Start new shell. Try these hotkeys:

  • alt+c -> recursive subdir search
  • ctrl+t -> recursive file search
  • ctrl+r -> search history (can be pressed after typing, fuzzy search, search in any order. Perfection
  • alt+up -> Go Up a Dir
  • alt+left -> Go to prev dir in history
  • z visited_dir_nameĀ > jump to dir (also check zi command for interactive mode)

Optional powerlevel10k Theme

  1. Install:
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
  1. Edit ~/.zshrc
#Setup theme 
ZSH_THEME="powerlevel10k/powerlevel10k"  
  1. Start new shell. follow wizard

Next Steps

Learn more about the fzf plugin we installed above. Check the following video :


dated June 2022