Skip to content

Instantly share code, notes, and snippets.

@brccabral
Last active March 3, 2025 20:05
Show Gist options
  • Save brccabral/1f96f8f3f55b69069c414a6e1879dccc to your computer and use it in GitHub Desktop.
Save brccabral/1f96f8f3f55b69069c414a6e1879dccc to your computer and use it in GitHub Desktop.
ZSH install and customizations

ZSH install and customizations

My personal instructions

  1. install
sudo apt install zsh

1.1 Change $ZDOTDIR path

ZSH needs many configuration files, .zshenv, .zprofile, .zshrc, and others. Change ZDOTDIR in the system wide .zshenv. Then, make sure to create all these config files in the ZDOTDIR path.

sudo nano /etc/zsh/zshenv
# add this line at the end of the file
export ZDOTDIR="$HOME"/.config/zsh
  1. check version
zsh --version
  1. change default shell
chsh -s $(which zsh)
  1. run it (it won't be default in GNOME terminal until you logout/login)
exec zsh
  1. install customization dependencies
sudo apt install curl git
  1. install Oh-My-Zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
  1. install fonts
    download fonts
wget https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Regular.ttf
wget https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Bold.ttf
wget https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Italic.ttf
wget https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Bold%20Italic.ttf

Move them to ~/.local/share/fonts/ (KDE Plasma ~/.fonts/m/)

mkdir -p ~/.local/share/fonts/
mv *.ttf ~/.local/share/fonts/
# mv *.ttf ~/.fonts/m/

Or (double click the file)
Change the terminal font.

  1. Install P10k
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
  1. Set ZSH_THEME="powerlevel10k/powerlevel10k" in ~/.zshrc
  2. run zsh again, should trigger p10k
exec zsh
  1. if it doesn't start automatically
p10k configure
  1. Install zsh-autosuggestions
git clone --depth=1 https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

add zsh-autosuggestions to ~/.config/zsh/.zshrc plugins
13. install zsh-syntax-highlighting

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

add zsh-syntax-highlighting to ~/.config/zsh/.zshrc plugins
14. install Dracula Highlighting for zsh-syntax-highlighting clone the repo

git clone --depth=1 https://github.com/dracula/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/dracula-zsh-syntax-highlighting

source dracula .sh from ~/.config/zsh/.zshrc before the plugins.

# on raspberrypi I had to set ZSH_CUSTOM
ZSH_CUSTOM=$ZSH/custom
source ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/dracula-zsh-syntax-highlighting/zsh-syntax-highlighting.sh
  1. Change ZSH_COMPDUMP location in ~/.config/zsh/.zshrc before line source $ZSH/oh-my-zsh.sh

Oh-My-Zsh creates many files .zcompdump in $HOME, hide it inside ~/.oh-my-zsh/

# oh-my-zsh creates many files .zcompdump in $HOME, hide it inside ~/.oh-my-zsh/
export ZSH_COMPDUMP=$ZSH/cache/.zcompdump-$HOST-$ZSH_VERSION
source $ZSH/oh-my-zsh.sh
  1. review ~/.config/zsh/.zshrc and ~/.p10k.sh based on files below

  2. Create ~/.config/zsh/.zprofile

emulate sh -c 'source $HOME/.profile'
  1. Create ~/.config/zsh/.zshenv

For some reason .zsh_history does not consider ZDOTDIR

export HISTFILE="${ZDOTDIR}/.zsh_history"

Original instructions

# set context to show hostname, depends on POWERLEVEL9K_CONTEXT_{DEFAULT,SUDO}_{CONTENT,VISUAL_IDENTIFIER}_EXPANSION
typeset -g POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(
# =========================[ Line #1 ]=========================
os_icon # os identifier
context # user@hostname
dir # current directory
# =========================[ Line #2 ]=========================
newline # \n
vcs # git status
virtualenv # python virtual environment (https://docs.python.org/3/library/venv.html)
# =========================[ Line #3 ]=========================
newline # \n
prompt_char # prompt symbol
)
# comment context and virtualenv from RIGHT elements
typeset -g POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(
#context
#virtualenv
)
# change context background/foreground colors
# Default context color (no privileges, no SSH).
typeset -g POWERLEVEL9K_CONTEXT_FOREGROUND=255
typeset -g POWERLEVEL9K_CONTEXT_BACKGROUND=67
# show only hostname, not username
# Default context format (no privileges, no SSH): user@hostname.
#typeset -g POWERLEVEL9K_CONTEXT_TEMPLATE='%n@%m'
typeset -g POWERLEVEL9K_CONTEXT_TEMPLATE='@%m'
# context shows only on SSH sessions by default. To show in normal sessions, comment POWERLEVEL9K_CONTEXT_{DEFAULT,SUDO}_{CONTENT,VISUAL_IDENTIFIER}_EXPANSION
emulate sh -c 'source $HOME/.profile'
export HISTFILE="${ZDOTDIR}/.zsh_history"
## added automatically
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
## added automatically
export ZSH="$HOME/.oh-my-zsh"
export ZSH="$ZDOTDIR/ohmyzsh" # raspberrypi
ZSH_THEME="powerlevel10k/powerlevel10k"
# on raspberrypi I had to set ZSH_CUSTOM
ZSH_CUSTOM=$ZSH/custom
# Dracula Theme (for zsh-syntax-highlighting)
# https://github.com/dracula/zsh-syntax-highlighting
source ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/dracula-zsh-syntax-highlighting/zsh-syntax-highlighting.sh
# .....................
plugins=(git zsh-autosuggestions zsh-syntax-highlighting)
# oh-my-zsh creates many files .zcompdump in $HOME, hide it inside ~/.oh-my-zsh/
export ZSH_COMPDUMP=$ZSH/cache/.zcompdump-$HOST-$ZSH_VERSION
source $ZSH/oh-my-zsh.sh
## added automatically
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
## not using at the moment
#source $(dirname $(gem which colorls))/tab_complete.sh
## not using at the moment
#source ~/.local/share/git/completion/git-prompt.sh
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
if [ -f ~/.bash_exports ]; then
. ~/.bash_exports
fi
if [ -f ~/.bash_functions ]; then
. ~/.bash_functions
fi
# https://github.com/atuinsh/atuin
eval "$(atuin init zsh --disable-up-arrow)"
## not using at the moment
# allow use of glob chars like ? . *
# execute_program https://example.com?something
#unsetopt nomatch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment