on Productivity tools - Tmux and Zsh

In this post, we'll cover two great tools which will drastically your command line experience. Zsh is an alternative shell to the default Bash. It's like Bash on steroids with more interactive features. Tmux is a terminal multiplexer with many features and can be seen as an alternative to GNU Screen.


ZSH can do everything that BASH can, plus a bunch of other useful and cool things such as: spelling correction, better tab completion, extended globbing, interactive path expansion, fully customisable and more ...

If you don't have it already, install ZSH, by issuing:

sudo apt-get install zsh # Ubuntu
sudo pacman -S zsh       # Arch Linux

Change the default shell from bash to zsh:

sudo usermod -s $(which zsh) $USER

To start using Zsh as the default shell you should log out and log back in.

Instead of manually configuring the Zsh configuration we can take advantage of existing Zsh frameworks. The two most popular community driven Zsh frameworks are oh-my-zsh and prezto. Both of them are great, well-documented frameworks with active community and it's up to your personal preferences which one you'll choose. Although prezto may be faster, I personally prefer oh-my-zsh because it is more actively developed and comes bundled with a ton of helpful functions, helpers, plugins and themes.

Install oh-my-zsh

Install Git if you already don't have it:

sudo apt-get install git # Ubuntu
sudo pacman -S git       # Arch Linux

In order to install oh-my-zsh you'll need either curl or wget.

# Using curl
curl -L http://install.ohmyz.sh | sh
# Using wget
wget --no-check-certificate http://install.ohmyz.sh -O - | sh

I'm not going into the details on how to customize your oh-my-zsh configuration because it's very well documented here.


To install the lates Tmux version 1.9a on a Ubuntu, run the following command:

sudo apt-get install software-properties-common
sudo add-apt-repository ppa:pi-rho/dev
sudo apt-get update
sudo apt-get install tmux

or, if you run Arch Linux:

sudo pacman -S tmux

Although you can use the tmux with its default configuration, i prefer to create user-specific configuration file ~/.tmux.conf and modify it according to my perfences. By default, tmux command key bindings are prefixed with Ctrl-b, Because I have used screen for many years before I've discovered tmux I like to change key bindings to Ctrl-a .

Below is my current Tmux configuration (~/.tmux.conf):

# GNU screen key bindings
unbind C-b
set -g prefix C-a
bind C-a send-prefix

# Improve colors
set -g default-terminal 'screen-256color'

# start window numbers at 1 and make pane numbering consistent with windows
set -g base-index 1
set-window-option -g pane-base-index 1

# renumber windows when a window is closed
set -g renumber-windows on

# Status Bar
set-option -g status-interval 1
set-option -g status-left ''
set-option -g status-right '%l:%M%p'
set-window-option -g window-status-current-fg magenta
set-option -g status-fg default
set-option -g status-bg black

# increase scrollback lines
set -g history-limit 10000

# Notifications
setw -g monitor-activity on
set -g visual-activity on

# Window && Pane Switching/Resizing Using Mouse
# set-option -g mouse on
# set-option -g mouse-select-window on
# set-option -g mouse-select-pane on
# set-option -g mouse-resize-pane on

# force a reload of the config file
unbind r
bind r source-file ~/.tmux.conf

You can list all all command keys with

tmux list-keys


Ctrl-a ?

Using Tmux sessions

tmux                           # new tmux session
tmux new -s mySession          # new session with a name
tmux ls                        # list sessions
tmux a                         # attach to session
tmux a -t mySession            # attach to a named session 
tmux kill-session -t mySession # kill session
Ctrl-a d                       # dettach from a session

Using Tmux windows

Ctrl-a c  # new window
Ctrl-a w  # list windows
Ctrl-a l  # move to previously selected window
Ctrl-a n  # move to the next window
Ctrl-a p  # move to the previous window
Ctrl-a f  # find window
Ctrl-a ,  # name window
Ctrl-a &  # kill window

Using Tmux panes

Ctrl-a %       # vertical split
Ctrl-a "       # horizontal split
Ctrl-a o       # swap panes
Ctrl-a q       # show pane numbers
Ctrl-a ←/→/↑/↓ # move focus to left/right/upper/lower pane
Ctrl-a x       # kill pane
Ctrl-a +       # break pane into window (e.g. to select text by mouse to copy)
Ctrl-a -       # restore pane from window
Ctrl-a ⍽       # toggle between layouts
Ctrl-a q       # Show pane numbers
Ctrl-a {       # Move the current pane left
Ctrl-a }       # Move the current pane right
Ctrl-a z       # toggle pane zoom
Ctrl-a !       # close other panes except the current one
Ctrl-a [       # enter copy mode (then use emacs select/yank keys)
               # press CTRL-SPACE or [email protected] to start selecting text
               # move cursor to end of desired text
               # press ALT-w to copy selected text
Ctrl-a ]       # paste copied text