Zsh

Installing

Install shell :

sudo {dnf,apt} install zsh
zsh --version

Install oh-my-ssh :

sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

Install zsh-autosuggestions :

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

Install zsh-syntax-hightlighting :

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

Install powerlevel9k :

git clone https://github.com/bhilburn/powerlevel9k.git ~/.oh-my-zsh/custom/themes/powerlevel9k
sudo dnf install powerline-fonts.noarch

Create completion workspace :

mkdir -p ~/.zsh/completion

Configuration

Update or create ~/.zshrc :

export ZSH=$HOME/.oh-my-zsh
ZSH_THEME="dogenpunk"
plugins=(
    git
    zsh-autosuggestions
        )
source $ZSH/oh-my-zsh.sh
source $HOME/.oh-my-zsh/custom/plugins/syntax-highlighting/zsh-syntax-highlighting.zsh
fpath=(~/.zsh/completion $fpath)
autoload -U compinit
compinit
zstyle ':completion:*' menu select=2
HISTSIZE=80000           # nombre de lignes en mémoire
HISTFILE=~/.zsh_history  # fichier de sauvegarde
SAVEHIST=50000           # nombre d'entrées à enregistrer
HISTDUP=erase            # effacer les doublons
setopt appendhistory     # ajout des entrées en mode append
setopt sharehistory      # partage de l'historique entre terminaux
setopt incappendhistory  # ajout immédiat à l'historique

If you want powerlevel9k theme, update .zshrc :

ZSH_THEME="powerlevel9k/powerlevel9k"
...
POWERLEVEL9K_CUSTOM_ICON="echo -e '\uf015'"
POWERLEVEL9K_CUSTOM_ICON_BACKGROUND=blue
POWERLEVEL9K_SSH_ICON="\uf68c"
if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then
    POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_icon ssh context dir dir_writable vcs virtualenv)
else
    POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_icon dir dir_writable vcs virtualenv)
fi
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status time battery)
POWERLEVEL9K_PROMPT_ON_NEWLINE=true
POWERLEVEL9K_MULTILINE_FIRST_PROMPT_PREFIX="\u256d\u2500 "
POWERLEVEL9K_MULTILINE_LAST_PROMPT_PREFIX="\u2570\uf460 "
POWERLEVEL9K_TIME_FORMAT="%D{\ue383 %H:%M \uf073 %d/%m/%y}"
POWERLEVEL9K_DIR_HOME_BACKGROUND=blue
POWERLEVEL9K_DIR_HOME_SUBFOLDER_BACKGROUND=blue
POWERLEVEL9K_DIR_HOME_DEFAULT_BACKGROUND=blue
POWERLEVEL9K_DIR_HOME_FOREGROUND=black
POWERLEVEL9K_DIR_HOME_SUBFOLDER_FOREGROUND=black
POWERLEVEL9K_DIR_HOME_DEFAULT_FOREGROUND=black
POWERLEVEL9K_TIME_FOREGROUND=black
POWERLEVEL9K_TIME_BACKGROUND=yellow
POWERLEVEL9K_STATUS_OK_BACKGROUND=yellow
POWERLEVEL9K_STATUS_OK_FOREGROUND=green
POWERLEVEL9K_STATUS_ERROR_BACKGROUND=yellow
POWERLEVEL9K_STATUS_ERROR_FOREGROUND=red
POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND=(yellow yellow yellow yellow yellow)
POWERLEVEL9K_BATTERY_LOW_FOREGROUND=black
POWERLEVEL9K_BATTERY_CHARGING_FOREGROUND=black
POWERLEVEL9K_BATTERY_CHARGED_FOREGROUND=black
POWERLEVEL9K_BATTERY_DISCONNECTED_FOREGROUND=black
POWERLEVEL9K_BATTERY_STAGES=($'\uf244' $'\uf243' $'\uf242' $'\uf241' $'\uf240')
POWERLEVEL9K_VIRTUALENV_FOREGROUND=black
POWERLEVEL9K_VIRTUALENV_BACKGROUND=darkorange
POWERLEVEL9K_PYTHON_ICON='🐍 '

For root account, , update .zshrc :

HOSTNAME=$(hostname|cut -d '.' -f 1)
POWERLEVEL9K_ROOT_ICON="\xf0\x9f\x9c\xb2 root@${HOSTNAME}"
POWERLEVEL9K_ROOT_INDICATOR_BACKGROUND=black
POWERLEVEL9K_ROOT_INDICATOR_FOREGROUND=yellow

Note

See oh-my-zsh themes page

Improve prompt

Downloads nerd-fonts :

wget https://github.com/ryanoasis/nerd-fonts/releases/download/v2.0.0/Hack.zip
mkdir hack && unzip Hack.zip -d hack

Install nerd-fonts :

sudo mv hack /usr/share/fonts/truetype
fc-cache -f -v
fc-list | grep "Hack"

Warning

If you don’t find nerd-fonts in your term preferences, on gnome do this:

gsettings get org.gnome.desktop.interface monospace-font-name
'Monospace 12'
gsettings set org.gnome.desktop.interface monospace-font-name 'Hack Nerd Font 12'

Screenshot

../_images/zsh_prompt.png

Zsh prompt & Byobu status bar