Useful ZSH shortcuts and setup commands for a faster pentesting shell.
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 lineCTRL + E # Move to the end of the lineCTRL + [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 positionCTRL + U # (zsh) If you're using the zsh, this will clear the entire lineCTRL + K # Clear the characters on the line after the current cursor positionESC + [backspace] # Delete the word in front of the cursorCTRL + W # Delete the word in front of the cursorALT + D # Delete the word after the cursorCTRL + R # Search historyCTRL + G # Escape from search modeCTRL + - # Undo the last changeCTRL + L # Clear screenCTRL + S # Stop output to screenCTRL + Q # Re-enable screen outputCTRL + C # Terminate/kill current foreground processCTRL + 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 abcInstall ZSH and Powerlevel10K with syntax highlighting and zsh-autosuggestions
# Install1. sudo apt-get update2. sudo apt upgrade3. sudo apt install zsh4. sudo apt-get install powerline fonts-powerline5. git clone https://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh6. cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc7. 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 Highlighting9. git clone https://github.com/zsh-users/zsh-syntax-highlighting.git "$HOME/.zsh-syntax-highlighting" --depth 110. echo "source $HOME/.zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" >> "$HOME/.zshrc"# Auto suggestions based on history11. sudo apt install zsh-autosuggestions12. 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_historyHISTSIZE=100000SAVEHIST=100000setopt INC_APPEND_HISTORY # Immediately append commands to the history filesetopt SHARE_HISTORY # Share history across all sessionssetopt HIST_IGNORE_ALL_DUPS # Don't record a command that's already in historysetopt HIST_REDUCE_BLANKS # Remove superfluous blanks before recordingsetopt HIST_SAVE_NO_DUPS # Don't write duplicates to the history filesetopt EXTENDED_HISTORY # Save timestamped entriesunsetopt EXTENDED_HISTORY# Source .zshrcsource .zshrcWith the above, your terminal will look clean like mine below and have auto-suggestions with syntax highlighting.




