Improved Terminal for Maximum Productivity

Ferdous Shourove
3 min readApr 5, 2021

This article is about modifying my terminal for maximum productivity. This is a reference to my future self. Time and again I go through the same steps and each time I have to go through the same discovery phase of what I like the most and what is suitable for my work. So putting all those things here once in for all for future reference.

This is just the bare minimum. I plan to update this whenever I find something worth adding to my command line.

We need ZSH. But if you need to remove a broken ZSH installation first before installing a fresh one, follow the bellow link

Uninstall ZSH

Install ZSH

brew install zsh

Make ZSH your default Shell

chsh -s /usr/local/bin/zsh

Install Oh-my-zsh

Run the following command to install oh-my-zsh

sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

For more details see the docs

Install powerlevel10k

Run the following command to install powerlevel10k font

git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k

for more details see the docs

Update ZSH_THEME variable in ~/.zshrc

ZSH_THEME="powerlevel10k/powerlevel10k"

Configure powerlevel10k

Run the following command in your terminal and follow the instructions.

p10k configure

Install ZSH Plugins

Clone the Git repos and update the plugins variable in ~/.zshrc

zsh-syntax-highlighting

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

zsh-autosuggestions

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

zsh-kubectl-prompt

git clone https://github.com/superbrothers/zsh-kubectl-prompt ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-kubectl-prompt

Update plugins variable in ~/.zshrc

plugins=(git zsh-completions zsh-syntax-highlighting zsh-autosuggestions docker docker-compose zsh-kubectl-prompt kubectl)

Use MesloLGS NF Font in iTerm2 and VSCode

Use MesloLGS NF font because it can show all the icons properly. I tried a few other fonts, they seem to break the icons.

iTerm2 > Preferences > Profiles > Text > Font

MesloLGS NF

VSCode

"terminal.integrated.fontFamily": "MesloLGS NF"

Use fzf for Fuzzy Search Through Command History

Using Alt/Cmd + Right/Left Arrow in iTerm

Improve ls commands

if [ -x "$(command -v exa)" ]; then
alias ls="exa"
alias la="exa --long --all --group"
fi

Pretty Print JSON and YAML

Terminal Based File Manager: Ranger

Troubleshooting

One of the errors that I got while going through this process was this, shown in the screenshot below.

I fixed this issue using the following commands

export CLOUDSDK_PYTHON=python2
gcloud components update
export CLOUDSDK_PYTHON=python3

Remove Duplicates From fzf History

Add the following lines in your .zshrc file and reload

setopt EXTENDED_HISTORY
setopt HIST_EXPIRE_DUPS_FIRST
setopt HIST_IGNORE_DUPS
setopt HIST_IGNORE_ALL_DUPS
setopt HIST_IGNORE_SPACE
setopt HIST_FIND_NO_DUPS
setopt HIST_SAVE_NO_DUPS
setopt HIST_BEEP

Important Links

--

--