Zsh (short for Z shell) is a powerful shell designed for interactive use, although it’s also a capable scripting language. Built on top of bash, it incorporates many features from ksh and tcsh while adding its own modern flair. If you’re still using the default terminal settings, you’re playing on “Hard Mode.” Switching to Zsh is like giving your command line a brain transplant; it becomes faster, smarter, and much more helpful.

If you want to skip the manual labour, install Oh My Zsh. It’s an open-source framework that manages your Zsh configuration for you. It comes with hundreds of plugins (like git, Docker, and Node) that provide even more shortcuts and tab-completion helpers.

ZSH Shortcuts

Here are some of the most useful ZSH shortcuts to improve your pentesting efficiency.

CTRL + A              #Move to the beginning of the line
CTRL + E              #Move to the end of the line
CTRL + [left arrow]   #Move one word backward (on some systems this is ALT + B)
CTRL + [right arrow]  #Move one word forward (on some systems this is ALT + F)
CTRL + U              #(bash) Clear the characters on the line before the current cursor position
CTRL + U              #(zsh) If you're using the zsh, this will clear the entire line
CTRL + K              #Clear the characters on the line after the current cursor position
ESC + [backspace]     #Delete the word in front of the cursor
CTRL + W              #Delete the word in front of the cursor
ALT + D               #Delete the word after the cursor
CTRL + R              #Search history
CTRL + G              #Escape from search mode
CTRL + -              #Undo the last change
CTRL + L              #Clear screen
CTRL + S              #Stop output to screen
CTRL + Q              #Re-enable screen output
CTRL + C              #Terminate/kill current foreground process
CTRL + Z              #Suspend/stop current foreground process
!!                    #Execute last command in history
!abc                  #Execute last command in history beginning with abc
!abc:p                #Print last command in history beginning with abc

Install ZSH and Powerlevel10K with syntax highlighting and zsh-autosuggestions

#Install
1. sudo apt-get update
2. sudo apt upgrade
3. sudo apt install zsh
4. sudo apt-get install powerline fonts-powerline
5. git clone https://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh
6. cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
7. git clone --depth=1 https://github.com/romkatv/powerlevel10k.git "${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k"
8. Open ~/.zshrc, find the line that sets ZSH_THEME, and change its value to "powerlevel10k/powerlevel10k"

#Syntax Highlighting
9. git clone https://github.com/zsh-users/zsh-syntax-highlighting.git "$HOME/.zsh-syntax-highlighting" --depth 1
10. echo "source $HOME/.zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" >> "$HOME/.zshrc"

#Auto suggestions based on history
11. sudo apt install zsh-autosuggestions
12. Paste the below into .zshrc

if [ -f /usr/share/zsh-autosuggestions/zsh-autosuggestions.zsh ]; then
    . /usr/share/zsh-autosuggestions/zsh-autosuggestions.zsh
    # change suggestion color
    ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=#999'
fi

#Enable proper history (Across tabs and realtime etc. I use konsole so this works for me)
13. Copy the below to .zshrc

HISTFILE=~/.zsh_history
HISTSIZE=100000
SAVEHIST=100000
setopt INC_APPEND_HISTORY       # Immediately append commands to the history file
setopt SHARE_HISTORY            # Share history across all sessions
setopt HIST_IGNORE_ALL_DUPS     # Don’t record a command that’s already in history
setopt HIST_REDUCE_BLANKS       # Remove superfluous blanks before recording
setopt HIST_SAVE_NO_DUPS        # Don’t write duplicates to the history file
setopt EXTENDED_HISTORY         # Save timestamped entries
unsetopt EXTENDED_HISTORY

#Source .zshrc
source .zshrc

With the above, your terminal will look clean like mine below and have auto-suggestions with syntax highlighting.

ZSH Terminal