Skip to content

zsh

Startup scripts

Startup scripts are executed in the following order:

  1. ~/.zshenv
  2. ~/.zprofile
  3. ~/.zshrc: non-login shells
  4. ~/.zlogin

~/.zshenv (Environment Variables)

  • It's executed for all types of shell (login, non-login, scripts, etc)
  • It is the first file to be sourced during initialization
  • Commonly used to set for environment variables that should always be available, regardless of how zsh is invoked
  • This file should not include shell options
export XDG_CONFIG_HOME="$HOME/.config"
export ZDOTDIR="$HOME/.config/zsh"

export EDITOR=vim

export LC_ALL="en_US.UTF-8"
export GOPATH="$HOME/.local/share/go"

export LESS="-R"

umask 022

~/.zprofile

  • It's executed only for login shells
  • Executed before ~/.zshrc

~/.zshrc

  • It's executed only for interactive shells

~/.zlogin

  • It's executed only for login shells
  • Executed after ~/.zshrc
# welcoming message
echo "Welcome, $USER!"

# Start the i3 window manager
# Not usually done anymore since nowadays DE is usually started at boot
exec i3

~/.zlogout

clear
echo "Goodbye, $(whoami)! Have a great day!"

Environment variables

  • ZDOTDIR

Oh My Zsh

sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

Plugins

vi ~/.zshrc
plugins=(
  git
  bundler
  dotenv
  osx
  rake
  rbenv
  ruby
)

Themes

ZSH_THEME="robbyrussell" # Default theme
ZSH_THEME="agnoster" # fancy
ZSH_THEME="random" # random on each start
ZSH_THEME_RANDOM_CANDIDATES=(
  "robbyrussell"
  "agnoster"
)
ZSH_THEME_RANDOM_IGNORED=(pygmalion tjkirch_mod)

Installation folder

  • ~/.oh-my-zsh
echo $ZSH