term Zsh

Overview

Zsh is a shell designed for interactive use, although it is also a powerful scripting language.

Oh My Zsh

Installation

Install the required packages.

sudo {dnf,apt,pacman} install zsh curl git
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 \
 ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

Install zsh-syntax-hightlighting.

git clone https://github.com/zsh-users/zsh-syntax-highlighting.git \
 ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

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 $ZSH/custom/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
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

See also

See the theme’s page.

Powerlevel9k

Installation

Install nerd-fonts.

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

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'

Install the theme.

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

Configuration

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

Screenshot

zsh_p9k

Powerlevel10k

Installation

Install nerd-fonts.

wget https://github.com/ryanoasis/nerd-fonts/releases/download/v2.1.0/Meslo.zip
mkdir MesloNerdFont && unzip Meslo.zip -d MesloNerdFont/
sudo mv MesloNerdFont/ /usr/share/fonts/truetype/
fc-cache -v -f
fc-list

Install the theme.

git clone --depth=1 https://github.com/romkatv/powerlevel10k.git \
${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k\n

Configuration

Edit .zshrc.

ZSH_THEME="powerlevel10k"
p10k --help
  Usage: p10k command [options]

  Commands:

    configure  run interactive configuration wizard
    reload     reload configuration
    segment    print a user-defined prompt segment
    display    show, hide or toggle prompt parts
    help       print this help message

  Print help for a specific command:

    p10k help command

See ~/.p10k.zsh.

Screenshot

zsh_p10k