DEV Community

Cover image for Lean ZSH terminal
thbe
thbe

Posted on • Originally published at thbe.org

Lean ZSH terminal

This post was originally published at thbe.org.

In the past two terminal posts (Enhance your macOS terminal and Enhance your macOS terminal - p10k) I showed how a fully-fledged terminal can look like. In this post, I'll concentrate on a lean terminal I'll for example use on my Raspberry PI boxes. This is how it should look like in the end:

Customized lean Terminal with oh-my-zsh

My Raspberry PIs are normally equipped with Raspbian in the minimal version. The standard shell on Debian is normally the bash shell, so we need to change it to ZSH first:

$ sudo apt-get clean all
$ sudo apt-get update
$ sudo apt-get -y install zsh zsh-autosuggestions zsh-syntax-highlighting
$ chsh -s $(which zsh)
$ grep $USER /etc/passwd
Enter fullscreen mode Exit fullscreen mode

The last command should end with something like :/usr/bin/zsh indicating that ZSH is now the primary shell of the account. As I'm looking for a lean configuration I will only install oh-my-zsh and a third party theme.

$ sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
Enter fullscreen mode Exit fullscreen mode

Finally, the third party theme needs to be installed. I used typewritten by reobin for this:

git clone https://github.com/reobin/typewritten.git $ZSH_CUSTOM/themes/typewritten
Enter fullscreen mode Exit fullscreen mode

Once everything is installed and in place, the components need to be configured. This is done primarily through the .zshrc configuration file. Here is the one that creates the configuration from the screenshot above:

# zsh configuration file
#
# Author: Thomas Bendler <code@thbe.org>
# Date:   Thu Jan  2 17:53:48 GMT 2020

# Add local sbin to $PATH.
export PATH="/usr/local/sbin:${PATH}"

# Path to the oh-my-zsh installation.
export ZSH="${HOME}/.oh-my-zsh"

# Use case-sensitive completion.
CASE_SENSITIVE="true"

# Define how often to auto-update (in days).
export UPDATE_ZSH_DAYS=7

# Enable command auto-correction.
ENABLE_CORRECTION="true"

# Display red dots whilst waiting for completion.
COMPLETION_WAITING_DOTS="true"

# Configure history stamp format
HIST_STAMPS="yyyy-mm-dd"

# Plugin configuration
# Standard plugins can be found in ~/.oh-my-zsh/plugins/*
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Add wisely, as too many plugins slow down shell startup.
plugins=(
  ansible
  bundler
  colored-man-pages
  colorize
  common-aliases
  debian
  git
  nmap
  zsh-navigation-tools
  zsh_reload
)

# Use typewritten theme with multiline enabled
TYPEWRITTEN_MULTILINE=true
ZSH_THEME="typewritten/typewritten"

# Load zsh extensions
[ -e /usr/share/zsh-autosuggestions/zsh-autosuggestions.zsh ] && source /usr/share/zsh-autosuggestions/zsh-autosuggestions.zsh
[ -e /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh ] && source /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh

# Load oh-my-zsh framework
[ -e ${HOME}/.oh-my-zsh/oh-my-zsh.sh ] && source ${HOME}/.oh-my-zsh/oh-my-zsh.sh
Enter fullscreen mode Exit fullscreen mode

Top comments (2)

Collapse
 
moopet profile image
Ben Sinclair

Something about "lean" and "I will install oh-my-zsh" troubles me. OMZ is a beast.

Collapse
 
thbe profile image
thbe

I can't and I won't really argue against your statement, OMZ is indeed a beast and OMZ won't be lean any longer if you activate a big bunch of plugins. You have to be carefull with the plugins, the OMZ core itself is quite lean ... 😉