Terminal Boost with tmux and Zsh (oh-my-zsh)

Enhance your shell experience and become a terminal power user

If you’ve ever watched a developer work in their terminal and wondered how they make it look so sleek and productive, you’re in the right place. Today, we’ll transform your basic terminal into a powerful, beautiful, and efficient workspace using two incredible tools: Zsh with Oh My Zsh and tmux.

By the end of this guide, you’ll have a terminal that not only looks professional but also boosts your productivity with features like intelligent autocompletion, syntax highlighting, and the ability to manage multiple sessions seamlessly.

What We’re Building

Before we dive in, let’s understand what we’re setting up:

  • Zsh (Z Shell): A powerful shell that’s more feature-rich than the default bash
  • Oh My Zsh: A framework that makes Zsh incredibly easy to configure and customize
  • Spaceship Theme: A beautiful, informative prompt that shows git status, battery, and more
  • tmux: A terminal multiplexer that lets you run multiple terminal sessions in one window

Think of this as giving your terminal a complete makeover – from a basic black screen to a developer’s dream workspace.

Step 1: Installing Zsh

First, let’s check if Zsh is already installed and install it if needed.

1
2
3
4
5
6
# Check if zsh is installed
zsh --version

# If not installed, install it
sudo apt update
sudo apt install zsh

After installation, verify it worked:

1
zsh --version

You should see something like zsh 5.8 or similar.

Step 2: Installing Oh My Zsh

Oh My Zsh is what makes Zsh truly shine. It provides hundreds of plugins and themes out of the box.

Run this command to install Oh My Zsh:

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

If you don’t have curl, you can use wget:

1
sh -c "$(wget https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"

The installer will:

  1. Download Oh My Zsh
  2. Create a backup of your existing .zshrc file
  3. Create a new .zshrc with Oh My Zsh configuration
  4. Ask if you want to make Zsh your default shell

Say yes when prompted to make Zsh your default shell. If you miss this step, you can run:

1
chsh -s $(which zsh)

You’ll need to log out and log back in for the shell change to take effect.

Step 3: Installing the Spaceship Theme

The Spaceship theme is one of the most popular and informative themes for Oh My Zsh. It shows your current directory, git branch, status, and much more at a glance.

1
git clone https://github.com/spaceship-prompt/spaceship-prompt.git "$ZSH_CUSTOM/themes/spaceship-prompt" --depth=1

Create a symbolic link:

1
ln -s "$ZSH_CUSTOM/themes/spaceship-prompt/spaceship.zsh-theme" "$ZSH_CUSTOM/themes/spaceship.zsh-theme"

Step 4: Configuring Your .zshrc

Now let’s configure your .zshrc file to use the Spaceship theme and add some useful plugins.

Open your .zshrc file:

1
nano ~/.zshrc

Find the line that says ZSH_THEME="robbyrussell" and change it to:

1
ZSH_THEME="spaceship"

Next, find the plugins section. It probably looks like:

1
plugins=(git)

Replace it with these useful plugins:

1
2
3
4
5
6
7
8
plugins=(
    git
    zsh-autosuggestions
    zsh-syntax-highlighting
    colored-man-pages
    extract
    web-search
)

Save and exit the file (in nano: Ctrl+X, then Y, then Enter).

Step 5: Installing Additional Zsh Plugins

The plugins we added need to be installed separately:

Install zsh-autosuggestions:

1
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

Install zsh-syntax-highlighting:

1
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

Step 6: Reload Your Configuration

Reload your Zsh configuration:

1
source ~/.zshrc

You should now see the beautiful Spaceship prompt! It will show:

  • Your current directory
  • Git branch and status (if you’re in a git repository)
  • Various other contextual information

Step 7: Installing tmux

Now let’s add tmux to supercharge your terminal workflow.

1
2
sudo apt update
sudo apt install tmux

Step 8: Basic tmux Configuration

Let’s create a basic tmux configuration to make it more user-friendly:

1
nano ~/.tmux.conf

Add this configuration:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# Set prefix key to Ctrl-a (instead of Ctrl-b)
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix

# Split panes using | and -
bind | split-window -h
bind - split-window -v
unbind '"'
unbind %

# Enable mouse mode
set -g mouse on

# Start windows and panes at 1, not 0
set -g base-index 1
setw -g pane-base-index 1

# Reload config file
bind r source-file ~/.tmux.conf \; display-message "Config reloaded!"

# Switch panes using Alt-arrow without prefix
bind -n M-Left select-pane -L
bind -n M-Right select-pane -R
bind -n M-Up select-pane -U
bind -n M-Down select-pane -D

# Status bar
set -g status-bg black
set -g status-fg white
set -g status-left-length 20
set -g status-left '#[fg=green][#S] '
set -g status-right '#[fg=yellow]%Y-%m-%d %H:%M'

Save and exit the file.

Step 9: Your First tmux Session

Let’s start using tmux! Here are the essential commands:

Start a new session:

1
tmux

Basic tmux commands (remember, prefix is Ctrl+a):

  • Ctrl+a + | - Split pane vertically
  • Ctrl+a + - - Split pane horizontally
  • Alt + Arrow keys - Move between panes
  • Ctrl+a + c - Create new window
  • Ctrl+a + n - Next window
  • Ctrl+a + p - Previous window
  • Ctrl+a + d - Detach from session

Managing sessions:

1
2
3
4
5
6
7
8
# List sessions
tmux ls

# Attach to a session
tmux attach -t session_name

# Create named session
tmux new-session -s my_project

Step 10: Customizing Your Spaceship Theme

You can customize the Spaceship theme by adding configuration to your .zshrc. Here are some popular customizations:

1
nano ~/.zshrc

Add these lines before the plugins=(git) line to customize your prompt:

1
2
3
4
# Spaceship theme customization
SPACESHIP_DIR_HOMESYMBOL="🏠"
SPACESHIP_CHAR_SYMBOL="🚀"
SPACESHIP_PROMPT_ADD_NEWLINE=true

You can also create a custom prompt alongside the Spaceship theme by adding this after the source $ZSH/oh-my-zsh.sh line:

1
2
# Custom prompt with time and user info
PROMPT='🚀 %F{green}%T%f %F{blue}%n@%m%f %F{cyan}%~%f %# '
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
# Character customization
SPACESHIP_CHAR_SYMBOL="❯"           # Change prompt character
SPACESHIP_CHAR_SUFFIX=" "           # Add space after character

# Directory customization  
SPACESHIP_DIR_HOMESYMBOL="🏠"       # Home directory symbol
SPACESHIP_DIR_TRUNC=3               # Number of directories to show

# Git customization
SPACESHIP_GIT_SYMBOL="🌱"           # Git branch symbol
SPACESHIP_GIT_BRANCH_COLOR="green"  # Branch name color

# Prompt behavior
SPACESHIP_PROMPT_ADD_NEWLINE=false  # Add newline before prompt
SPACESHIP_PROMPT_SEPARATE_LINE=true # Put prompt on separate line

Reload your configuration:

1
source ~/.zshrc

Step 11: Adding System Information Display (Optional)

For a more informative terminal experience, you can add a system information display that shows when you open your terminal. Add this to your .zshrc file after the source $ZSH/oh-my-zsh.sh line:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# System information display
echo -e "\e[32m"
echo "System Information:"
echo "==================="

# IP Address
ip=$(hostname -I | awk '{print $1}')
echo "IP Address  : $ip"

# CPU Info  
cpu=$(lscpu | grep 'Model name' | awk -F: '{print $2}' | xargs)
echo "CPU         : $cpu"

# Disk Usage
disk=$(df -h / | awk 'NR==2 {print $5 " used on " $1}')
echo "Disk Usage  : $disk"

# Memory Usage
mem=$(free -h | awk '/Mem:/ {print $3 "/" $2}')
echo "Memory Used : $mem"

# Network Interfaces
net=$(ip -o -4 addr show | awk '{print $2": "$4}' | paste -sd ", ")
echo "Interfaces  : $net"

echo -e "\e[0m"

If you want to add a custom banner with your name or project, you can install figlet and add:

1
2
3
4
5
6
7
# Install figlet first
sudo apt install figlet

# Then add to .zshrc
echo -e "\e[34m"
figlet -c -f slant "Your Name"
echo -e "\e[0m"

This will display a stylized ASCII art version of your text when you open the terminal.

Step 12: Useful Aliases and Functions

1
nano ~/.zshrc

Add these at the end:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# Useful aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'

# Git aliases
alias gs='git status'
alias ga='git add'
alias gc='git commit'
alias gp='git push'
alias gl='git log --oneline'
alias gd='git diff'

# tmux aliases
alias tl='tmux ls'
alias ta='tmux attach -t'
alias tn='tmux new-session -s'

# Quick navigation
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'

# Quick edit
alias zshrc='nano ~/.zshrc'
alias tmuxrc='nano ~/.tmux.conf'

Step 13: Testing Your Setup

Let’s test everything is working:

  1. Open a new terminal - You should see the Spaceship prompt
  2. Type a command - You should see syntax highlighting as you type
  3. Start typing a command you’ve used before - You should see gray autosuggestions
  4. Navigate to a git repository - The prompt should show branch information
  5. Start tmux with tmux
  6. Split your terminal with Ctrl+a + |
  7. Create a new window with Ctrl+a + c

Step 14: Pro Tips and Best Practices

Zsh Tips:

  • Press Tab twice to see all available completions
  • Use Ctrl+R to search command history
  • Type take project-name to create and enter a directory in one command
  • Use extract filename to automatically extract any archive format

tmux Tips:

  • Always name your sessions: tmux new-session -s project-name
  • Use tmux attach to resume your work exactly where you left off
  • Detach with Ctrl+a + d instead of closing terminal windows
  • Use multiple windows for different tasks in the same project

Workflow Suggestions:

  1. Start your day by creating a named tmux session for each project
  2. Use different windows within each session for different aspects (coding, testing, logs)
  3. Split panes to monitor multiple things simultaneously
  4. Detach when switching between projects, attach when resuming

Troubleshooting Common Issues

Spaceship theme not showing:

  • Ensure you’ve installed it correctly and set ZSH_THEME="spaceship" in .zshrc
  • Reload with source ~/.zshrc

Plugins not working:

  • Make sure you’ve cloned the plugin repositories to the correct locations
  • Check that the plugin names in your .zshrc match exactly

tmux key bindings not working:

  • Reload tmux config with Ctrl+a + r (if you added the reload binding)
  • Or restart tmux entirely

Permission issues:

  • Some commands might need sudo depending on your system
  • Make sure you own the files you’re trying to modify

Conclusion

Congratulations! You’ve successfully transformed your terminal into a powerful development environment. Your new setup includes:

Zsh with Oh My Zsh - A powerful shell with intelligent features
Spaceship theme - Beautiful, informative prompts
Essential plugins - Autosuggestions, syntax highlighting, and more
tmux - Professional session management
Custom configuration - Tailored to boost productivity

Your terminal is now equipped with:

  • Smart autocompletion that learns from your usage
  • Syntax highlighting that shows errors as you type
  • Git integration that displays repository status
  • Session management that persists your work
  • Split panes and multiple windows for multitasking

The best part? This is just the beginning. Both Oh My Zsh and tmux have extensive ecosystems of plugins and themes. As you become more comfortable, you can explore advanced features like custom functions, complex tmux layouts, and specialized plugins for your specific development needs.

Remember: the key to mastering these tools is daily usage. Start incorporating them into your regular workflow, and within a week, you’ll wonder how you ever worked without them.

Happy terminal-ing! 🚀