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 zsh
If 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 zsh
Zsh 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```
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
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
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH="$HOME/.oh-my-zsh"
# Set name of the theme to load ---
ZSH_THEME="powerlevel10k/powerlevel10k"
# Uncomment the following line to use case-sensitive completion.
# CASE_SENSITIVE="true"
# Uncomment the following line to use hyphen-insensitive completion.
# Case-sensitive completion must be off. _ and - will be interchangeable.
# HYPHEN_INSENSITIVE="true"
# Uncomment the following line to disable auto-setting terminal title.
# DISABLE_AUTO_TITLE="true"
# Uncomment the following line to enable command auto-correction.
# ENABLE_CORRECTION="true"
# Uncomment the following line if you want to change the command execution time
# stamp shown in the history command output.
# You can set one of the optional three formats:
# "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# or set a custom format using the strftime function format specifications,
# see 'man strftime' for details.
# HIST_STAMPS="mm/dd/yyyy"
# Would you like to use another custom folder than $ZSH/custom?
# ZSH_CUSTOM=/path/to/new-custom-folder
# Which plugins would you like to load?
# Standard plugins can be found in $ZSH/plugins/
# Custom plugins may be added to $ZSH_CUSTOM/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
plugins=(git autojump man python ruby history command-not-found zsh-autosuggestions zsh-syntax-highlighting zsh-completions)
source $ZSH/oh-my-zsh.sh
# User configuration
# export MANPATH="/usr/local/man:$MANPATH"
# You may need to manually set your language environment
export LANG=en_US.UTF-8
# Preferred editor for local and remote sessions
if [[ -n $SSH_CONNECTION ]]; then
export EDITOR='nano'
else
# export EDITOR='mvim'
# fi
# 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.