Tricks Of The Trades

Ubuntu 14.04 Z Shell (zsh) Installation and Basic Configuration

Pinterest LinkedIn Tumblr

Initial notes on installing plus base setup of Z Shell.

Listed here are some of its often touted features.

  • Auto-completion
  • Auto-correction
  • Scripting capabilities
  • Extensibility with modules
  • Improved globbing
  • Improved array handling

1 – Installation

Update the apt-get package manager’s database.

  1. $ sudo apt-get update

Install zsh through the apt-get package manager.

  1. $ sudo apt-get install zsh

2 – zsh-newuser-install

Run Z Shell for the first time to begin the new user config.

  1. $ zsh

If it doesn’t run or drop into the config then you can use:

  1. $ zsh /usr/share/zsh/functions/Newuser/zsh-newuser-install -f

Which will invoke the new user config manually.

Work through the new prompt screen as directed, typing 0 remembers an edit but does not save it until it is entered again on the root prompt screen.

  1. (1) Configure settings for history, i.e. command lines remembered
  2. and saved by the shell. (Recommended)

On the first option 0 will suffice and keeps the default settings.

  1. (2) Configure the new completion system. (Recommended.)

On the second option pressing 1 and turning on completion with default options is enough.

  1. (3) Configure how keys behave when editing command lines. (Recommended.)

With the third option you can set the key’s shell line editor to behave like Emacs or Vi. Set it with 1 and press e for emacs and v for vi.

  1. (4) Pick some of the more common shell options. These are simple “on”
  2. or “off” switches controlling the shell’s features.

In the fourth option I set 1, 2, and 3 to on, enabling them.

Finally entering 0 at the root menu exits and saves these new settings.

3 – Configuration Files Layout

When Z Shell starts, it sources the following files in this order:

Commands to set the global command search path and other system-wide environment variables; it should not contain commands that produce output.

For per-user configuration. Generally used for setting some useful environment variables.

This is a global configuration file, usually used for executing some general commands at login. On Arch Linux, by default it contains one line which sources the /etc/profile.

This file should be sourced by all Bourne-compatible shells upon login: it sets up an environment upon login and application-specific settings. Again on Arch Linux, Z Shell will also source this by default.

This file is generally used for automatic execution of user scripts upon login.

Another global configuration file.

The main user configuration file, and the one most often customised by users. This file is the one that will be used and changed in the next section.

Another global configuration file.

Same as the previous file before it, except for individual-user configuration.

A global configuration file, will be sourced when a login shell exits.

Same as the previous file before it, except for individual-user configuration.

4 – .zshrc Configuration File

The newly created zsh config file contents we just defined can be seen by opening it with a text editor. I’m using vim in this example.

  1. $ vim ~/.zshrc

At the end of the config file append the following:

  1. autoload -U promptinit compinit
  2. promptinit
  3. compinit
  4. prompt bart

Where bart is the name of the prompt you wish to use in your Z shell. For my example here I chose the bart theme.

To see possible prompts available and installed follow these commands from a Z shell terminal prompt.

  1. $ autoload -U promptinit
  2. $ promptinit
  3. $ prompt p

To apply any changes immediately in the config file you can use:

  1. $ source ~/.zshrc

Or exit and invoke a new Z Shell session.

  1. $ exit
  2. $ zsh

Finally to make Z Shell your Linux user’s default shell on this account enter:

  1. $ chsh -s $(which zsh)

Note: Do not include sudo with this previous command as it will alter the root user’s default shell instead.

The $SHELL variable stores your user’s current default shell path. It can be used to confirm the set default shell.

  1. $ echo $SHELL

Alternative Method via oh-my-zsh

Oh-My-Zsh is an open source, community-driven framework for managing your ZSH configuration. It comes bundled with a ton of helpful functions, helpers, plugins, themes, and a few things that make you shout…

Instead of a manual setup many people choose to use oh-my-zsh to manage their zsh installations.

It can be acquired most easily by using either curl or wget

  1. $ curl -L | sh


  1. $ wget –no-check-certificate -O – | sh

Enable any of the plugins you want in your ~/.zshrc config file by setting them active:


  1. plugins=(git ruby)

Change the ZSH_THEME environment variable in your ~/.zshrc to enable any of themes included in the package.


  1. ZSH_THEME=”af-magic”

Write A Comment