Terry : Zsh

Zsh - Z shell

The Z shell (zsh) is a Unix shell that can be used as an interactive login shell and as a powerful command interpreter for shell scripting. Zsh can be thought of as an extended Bourne shell with a large number of improvements, including some features of bash, ksh, and tcsh.

Shell options: Bash, fish and Zsh.

Enhance Zsh with oh-my-zsh

oh-my-zsh can be installed on Linux, Mac OS X and Cygwin (Windows).

What is oh-my-zsh

A handful of functions, auto-complete helpers, and stuff that makes you shout…


A community-driven framework for managing your zsh configuration. Includes 40+ optional plugins (rails, git, OSX, hub, capistrano, brew, ant, macports, etc), over 80 terminal themes to spice up your morning, and an auto-update tool so that makes it easy to keep up with the latest updates from the community. 


oh-my-zsh should work with any recent release of zsh, the minimum recommended version is 4.3.9.


curl -L https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh | sh


wget --no-check-certificate https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | sh

Sample output

$ wget --no-check-certificate https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | sh
--2012-12-18 14:57:22--  https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh
Resolving www-proxy.au.oracle.com (www-proxy.au.oracle.com)...
Connecting to www-proxy.au.oracle.com (www-proxy.au.oracle.com)||:80... connected.
Proxy request sent, awaiting response... 302 Found
Location: https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh [following]
--2012-12-18 14:57:23--  https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh
Connecting to www-proxy.au.oracle.com (www-proxy.au.oracle.com)||:80... connected.
Proxy request sent, awaiting response... 200 OK
Length: 1534 (1.5K) [text/plain]
Saving to: 'STDOUT'
100%[==========================================================================================>] 1,534       --.-K/s   in 0s      
2012-12-18 14:57:24 (578 MB/s) - written to stdout [1534/1534]
Cloning Oh My Zsh...
Cloning into '/home/terry/.oh-my-zsh'...
remote: Counting objects: 5589, done.
remote: Compressing objects: 100% (2138/2138), done.
remote: Total 5589 (delta 3325), reused 5153 (delta 3101)
Receiving objects: 100% (5589/5589), 732.52 KiB | 148 KiB/s, done.
Resolving deltas: 100% (3325/3325), done.
Looking for an existing zsh config...
Found ~/.zshrc. Backing up to ~/.zshrc.pre-oh-my-zsh
Using the Oh My Zsh template file and adding it to ~/.zshrc
Copying your current PATH and adding it to the end of ~/.zshrc for you.
Time to change your default shell to zsh!
Password: chsh: PAM authentication failed
         __                                     __   
  ____  / /_     ____ ___  __  __   ____  _____/ /_  
 / __ \/ __ \   / __ `__ \/ / / /  /_  / / ___/ __ \ 
/ /_/ / / / /  / / / / / / /_/ /    / /_(__  ) / / / 
\____/_/ /_/  /_/ /_/ /_/\__, /    /___/____/_/ /_/  

 ....is now installed.
sh: 38: source: not found

The manual way (Recommended)

1. Clone the repository

git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh

2. OPTIONAL Backup your existing ~/.zshrc file

cp ~/.zshrc{,.bak}

3. Create a new zsh config by copying the zsh template provided.

cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc

4. Set zsh as your default shell

chsh -s /bin/zsh

5. Start / restart zsh (open a new terminal is easy enough…)


If you want to override any of the default behavior, just add a new file (ending in .zsh) into the custom/ directory.

If you have many functions which go well together you can put them as a *.plugin.zsh file in the custom/plugins/ directory and then enable this plugin.

If you would like to override the functionality of a plugin distributed with oh-my-zsh, create a plugin of the same name in the custom/plugins/ directory and it will be loaded instead of the one in plugins/.


If you want to uninstall it, just run uninstall_oh_my_zsh from the command line and it’ll remove itself and revert you to bash (or your previous zsh config).

?  ~  uninstall_oh_my_zsh 
Removing ~/.oh-my-zsh
/home/terry/.oh-my-zsh/tools/uninstall.sh: 2: /home/terry/.oh-my-zsh/tools/uninstall.sh: [[: not found
Looking for original zsh config...
Switching back to bash
/home/terry/.oh-my-zsh/tools/uninstall.sh: 25: /home/terry/.oh-my-zsh/tools/uninstall.sh: source: not found
Thanks for trying out Oh My Zsh. It's been uninstalled.

Prezto - Zsh configuration framework

Prezto is the configuration framework for Zsh; it enriches the command line interface environment with sane defaults, aliases, functions, auto completion, and prompt themes.


Prezto will work with any recent release of Zsh, but the minimum recommended version is 4.3.11.

# Launch Zsh
# Clone the repository
git clone --recursive https://github.com/sorin-ionescu/prezto.git "${ZDOTDIR:-$HOME}/.zprezto"

# Create a new Zsh configuration by copying the Zsh configuration files provided

for rcfile in "${ZDOTDIR:-$HOME}"/.zprezto/runcoms/^README.md(.N); do ln -s "$rcfile" "${ZDOTDIR:-$HOME}/.${rcfile:t}"; done

# Set Zsh as your default shell
chsh -s /bin/zsh 

Open a new Zsh terminal window or tab.


Pull the latest changes and update submodules

git pull && git submodule update --init --recursive 


Prezto has many features disabled by default. Read the source code and accompanying README files to learn of what is available.

  • Modules
    Browse /modules to see what is available.
    Load the modules you need in ~/.zpreztorc then open a new Zsh terminal window or tab.
  • Themes
    For a list of themes, type prompt -l.
    To preview a theme, type prompt -p name.

Load the theme you like in ~/.zpreztorc then open a new Zsh terminal window or tab.

Sample zpreztorc file on Ubuntu

# Sets Prezto options.
# Authors:
#   Sorin Ionescu <sorin.ionescu@gmail.com>
# General
# Set case-sensitivity for completion, history lookup, etc.
# zstyle ':prezto:*:*' case-sensitive 'yes'
# Color output (auto set to 'no' on dumb terminals).
zstyle ':prezto:*:*' color 'yes'
# Set the Zsh modules to load (man zshmodules).
# zstyle ':prezto:load' zmodule 'attr' 'stat'
# Set the Zsh functions to load (man zshcontrib).
# zstyle ':prezto:load' zfunction 'zargs' 'zmv'
# Set the Prezto modules to load (browse modules).
# The order matters.
zstyle ':prezto:load' pmodule \
  'environment' \
  'terminal' \
  'editor' \
  'history' \
  'directory' \
  'spectrum' \
  'utility' \
  'completion' \
  'ssh' \
  'git' \
  'tmux' \
  'rsync' \
  'ruby' \
  'perl' \
  'node' \
  'rails' \
  'python' \
  'syntax-highlighting' \
  'history-substring-search' \
  'dpkg' \
# Editor
# Set the key mapping style to 'emacs' or 'vi'.
zstyle ':prezto:module:editor' key-bindings 'emacs'
# Auto convert .... to ../..
zstyle ':prezto:module:editor' dot-expansion 'yes'
# Git
# Ignore submodules when they are 'dirty', 'untracked', 'all', or 'none'.
# zstyle ':prezto:module:git:status:ignore' submodules 'all'
# GNU Utility
# Set the command prefix on non-GNU systems.
# zstyle ':prezto:module:gnu-utility' prefix 'g'
# History Substring Search
zstyle ':prezto:module:history-substring-search' color 'yes'
# Set the query found color.
zstyle ':prezto:module:history-substring-search:color' found ''
# Set the query not found color.
zstyle ':prezto:module:history-substring-search:color' not-found ''
# Set the search globbing flags.
zstyle ':prezto:module:history-substring-search' globbing-flags ''
# Pacman
# Set the Pacman frontend.
# zstyle ':prezto:module:pacman' frontend 'yaourt'
# Prompt
# Set the prompt theme to load.
# Setting it to 'random' loads a random theme.
# Auto set to 'off' on dumb terminals.
zstyle ':prezto:module:prompt' theme 'sorin'
# Ruby
# Auto switch the Ruby version on directory change.
# zstyle ':prezto:module:ruby:chruby' auto-switch 'yes'
# Screen
# Auto start a session when Zsh is launched in a local terminal.
# zstyle ':prezto:module:screen:auto-start' local 'yes'
# Auto start a session when Zsh is launched in a SSH connection.
# zstyle ':prezto:module:screen:auto-start' remote 'yes'
# Set the SSH identities to load into the agent.
# zstyle ':prezto:module:ssh:load' identities 'id_rsa' 'id_rsa2' 'id_github'
# Syntax Highlighting
# Set syntax highlighters.
# By default, only the main highlighter is enabled.
zstyle ':prezto:module:syntax-highlighting' highlighters \
  'main' \
  'brackets' \
  'pattern' \
  'cursor' \
# Set syntax highlighting styles.
# zstyle ':prezto:module:syntax-highlighting' styles \
#   'builtin' 'bg=blue' \
#   'command' 'bg=blue' \
#   'function' 'bg=blue'
# Terminal
# Auto set the tab and window titles.
# zstyle ':prezto:module:terminal' auto-title 'yes'
# Set the window title format.
# zstyle ':prezto:module:terminal:window-title' format '%n@%m: %s'
# Set the tab title format.
# zstyle ':prezto:module:terminal:tab-title' format '%m: %s'
# Tmux
# Auto start a session when Zsh is launched in a local terminal.
# zstyle ':prezto:module:tmux:auto-start' local 'yes'
# Auto start a session when Zsh is launched in a SSH connection.
# zstyle ':prezto:module:tmux:auto-start' remote 'yes'

NOTE: ~/.zpreztorc is a symbolic link to ~/.zprezto/runcoms/zpreztorc.




Book: From Bash to Z Shell

Zsh Reference Card