Terminal Cheat Sheet

Cheet says: The terminal is your portal to power!

Terminal Emulators

Popular Choices

Alacritty GPU-accelerated, Rust, config via YAML Kitty GPU-accelerated, Python scripting, images WezTerm GPU-accelerated, Rust, Lua config, multiplexer built-in iTerm2 macOS only, great features, tmux integration Ghostty New! Zig-based, fast, native feel Windows Terminal Windows, tabs, profiles, GPU rendering

Which to Choose?

Speed demon? → Alacritty or Ghostty Power user? → Kitty or WezTerm macOS native? → iTerm2 Windows? → Windows Terminal Simplicity? → Your OS default is fine!

Terminal Multiplexers

tmux Basics


Start/attach

tmux # New session tmux new -s name # Named session tmux attach -t name # Attach to session tmux ls # List sessions

Prefix key: Ctrl+b (then...)

Ctrl+b c # New window Ctrl+b n # Next window Ctrl+b p # Previous window Ctrl+b 0-9 # Go to window N Ctrl+b , # Rename window Ctrl+b & # Kill window

Panes

Ctrl+b % # Split vertical Ctrl+b " # Split horizontal Ctrl+b arrow # Navigate panes Ctrl+b z # Zoom pane (toggle) Ctrl+b x # Kill pane

Sessions

Ctrl+b d # Detach Ctrl+b s # List sessions Ctrl+b $ # Rename session

tmux Config (~/.tmux.conf)


Better prefix

set -g prefix C-a unbind C-b bind C-a send-prefix

Mouse support

set -g mouse on

Start windows at 1

set -g base-index 1

256 colors

set -g default-terminal "screen-256color"

Split with | and -

bind | split-window -h bind - split-window -v

Reload config

bind r source-file ~/.tmux.conf \; display "Reloaded!"

Zellij (Modern Alternative)


zellij                      # Start
zellij attach               # Attach to session
zellij -l welcome           # Start with layout

Default prefix: Ctrl+p (then...)

Ctrl+p n # New pane Ctrl+p d # Close pane Ctrl+p w # Toggle floating Ctrl+p t # New tab Ctrl+p h/j/k/l # Navigate

Shell Customization

Oh My Zsh


Install

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

Themes (~/.zshrc)

ZSH_THEME="robbyrussell" # Default ZSH_THEME="agnoster" # Fancy ZSH_THEME="powerlevel10k/powerlevel10k" # Best (install separately)

Plugins

plugins=(git docker kubectl zsh-autosuggestions zsh-syntax-highlighting)

Starship Prompt


Install

curl -sS https://starship.rs/install.sh | sh

Add to shell

Bash: eval "$(starship init bash)"

Zsh: eval "$(starship init zsh)"

Fish: starship init fish | source

Config: ~/.config/starship.toml

Colors & Fonts

ANSI Colors


Basic colors

echo -e "\033[31mRed\033[0m" echo -e "\033[32mGreen\033[0m" echo -e "\033[33mYellow\033[0m" echo -e "\033[34mBlue\033[0m"

Styles

echo -e "\033[1mBold\033[0m" echo -e "\033[4mUnderline\033[0m" echo -e "\033[7mReverse\033[0m"

256 colors

echo -e "\033[38;5;82mLime\033[0m"

True color (24-bit)

echo -e "\033[38;2;255;100;0mOrange\033[0m"

Nerd Fonts

Recommended fonts with icons: - JetBrains Mono Nerd Font - FiraCode Nerd Font - Hack Nerd Font - MesloLGS NF (for Powerlevel10k) Install: https://www.nerdfonts.com/

Terminal Tricks

Quick Navigation


Ctrl+a                      # Beginning of line
Ctrl+e                      # End of line
Ctrl+w                      # Delete word backward
Ctrl+u                      # Delete to beginning
Ctrl+k                      # Delete to end
Ctrl+y                      # Paste deleted text
Ctrl+r                      # Reverse search history
Ctrl+l                      # Clear screen

Job Control


Ctrl+z                      # Suspend process
bg                          # Resume in background
fg                          # Resume in foreground
jobs                        # List jobs
kill %1                     # Kill job 1

Useful Shortcuts


!!                          # Repeat last command
!$                          # Last argument
!^                          # First argument
!*                          # All arguments
!vim                        # Last command starting with 'vim'
^old^new                    # Replace in last command

Environment Setup

Essential ~/.bashrc or ~/.zshrc


History

HISTSIZE=10000 HISTFILESIZE=20000 HISTCONTROL=ignoreboth

Aliases

alias ll='ls -la' alias ..='cd ..' alias ...='cd ../..' alias g='git' alias k='kubectl'

Path

export PATH="$HOME/.local/bin:$PATH"

Editor

export EDITOR='vim' export VISUAL='vim'

Colors

export CLICOLOR=1

Debugging Terminal Issues


Check terminal type

echo $TERM

Check color support

tput colors

Reset terminal

reset stty sane

Check encoding

locale

Test true color

printf "\x1b[38;2;255;100;0mTrueColor\x1b[0m\n"

Remote Terminals


SSH with proper TERM

TERM=xterm-256color ssh user@host

Keep session alive

ssh -o ServerAliveInterval=60 user@host

Forward agent

ssh -A user@host

With tmux on remote

ssh user@host -t 'tmux attach || tmux new'

Resources

- Terminal.sexy - Color scheme designer - Nerdfonts.com - Patched fonts - tmuxcheatsheet.com - tmux reference - ohmyz.sh - Zsh framework