Depending on your platform, I use Termux for Android, Debian for Raspberry Pi and Kali on Windows Subsystem for Linux - WSL).. you can install Zsh with the following:
sudo apt install zshIf you're on Android using Termux, install by typing:
pkg install zshIf you’re on macOS and use Brew you can install Zsh with the following:
brew install zshZsh has a framework that you can use with it called Oh My Zsh this adds a lot of functionality to the shell, more on this in the guide.
Installing Oh My Zsh is as simple as:
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"Once installed you will have a ~/.zshrc file that you can edit to
add additional functionality to the shell.
The ~ here represents the home directory of your current logged in
user. So if you were to do cd ~ you would be in your home directory.
One of the joys of Zsh is that many commands are contextual so the
cd ~ can be shortened to ~.
Another nice one is changing directories, in bash you’d need to
cd .. to go back a directory. In Zsh you can use .. to go back a
directory. To go back three directories you can use ....
Anyway, the default .zshrc file is filled with helpful comments to
guide you through its usage.
If you cat out the contents of the .zshrc (with cat ~/.zshrc)
file you’ll see something similar to what I just linked.
You can edit the .zshrc file with your text editor of choice, I use
nano but you can use any text editor, VS Code even, use
code ~/.zshrc from the terminal to start editing with VS Code.
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
Basic quick zsh install instructions
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
Install git first
apt install git [Linux; Ubuntu, Kali] pkg install git [Termux and others] brew install git [MacOS]
Download zsh-autosuggestions by typing:
git clone https://github.com/zsh-users/zsh-autosuggestions.git $ZSH_CUSTOM/plugins/zsh-autosuggestions
Download zsh-syntax-highlighting by typing:
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $ZSH_CUSTOM/plugins/zsh-syntax-highlighting
nano ~/.zshrc find plugins=(git)
(this is to edit your zsh configuration profile that's in your current root/home directory)
Add zsh-autosuggestions & zsh-syntax-highlighting to plugins() like this
plugins=(git zsh-autosuggestions zsh-syntax-highlighting)
So if we take a look at my current configuration (modify or add as much you like that suits you and your terminal) ```.zshrc```
# -- [ Basic WSL2 Detection ] --
is_wsl() {
grep -qiE "(microsoft|wsl)" /proc/version
}
# -- [ Gitstatus crash fix ] --
export GITSTATUS_LOG_LEVEL=OFF
export POWERLEVEL9K_DISABLE_CONFIGURATION_WIZARD=true
export POWERLEVEL9K_INSTANT_PROMPT=quiet
# -- [ Theme / Oh My Zsh ] --
export ZSH="$HOME/.oh-my-zsh"
ZSH_THEME="powerlevel10k/powerlevel10k"
plugins=(
git
z
zsh-autosuggestions
zsh-syntax-highlighting
docker
command-not-found
history-substring-search
sudo
extract
man
)
source $ZSH/oh-my-zsh.sh
# -- [ Instant prompt cache ] --
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
# -- [ Language + Editor ] --
export LANG=en_US.UTF-8
export EDITOR='nano'
# -- [ LS Color scheme ] --
export LS_COLORS="rs=0:no=00:di=01;34:ln=01;36:so=01;33:pi=01;33:ex=01;32"
# -- [ Default directory on launch ] --
cd ~/panda
# -- [ PATH Purification for WSL2 ] --
if is_wsl; then
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$HOME/.local/bin:$HOME/bin"
fi
# -- [ PYENV Setup ] --
export PYENV_ROOT="$HOME/.pyenv"
[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
# -- [ Conda Setup (WSL-compatible)] --
if [[ -f "$HOME/miniconda3/etc/profile.d/conda.sh" ]]; then
source "$HOME/miniconda3/etc/profile.d/conda.sh"
conda activate base
fi
# -- [ Golang Setup ] --
export GOROOT="/usr/local/go"
export GOPATH="$HOME/go"
export PATH="$GOPATH/bin:$GOROOT/bin:$PATH"
# -- [ Neofetch on start ] --
neofetch
# -- [ Syntax Highlighting + Completion ] --
autoload -U compinit && compinit
# Compilation flags
# export ARCHFLAGS="-arch x86_64"
# For a full list of active aliases, run `alias`.
#
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"
source ~/powerlevel10k/powerlevel10k.zsh-theme
source "$ZSH/oh-my-zsh.sh"
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
Change your default shell
chsh -s $(which zsh)
You must log out from your user session and log back in to see this change.
Initialize your new zsh configuration
Once you open up a new terminal window, it should load zsh with your editted Oh My Zsh's configuration.