High-Performance Terminal Environment on Ubuntu

Table of Contents

  1. tmux — Terminal multiplexer
  2. tdocs.in — Technical documents
  3. Zsh — Feature-rich interactive shell
  4. Homebrew — Cross-platform package manager
  5. Helpful Tools
    • git — Version control system
    • curl — Transfer data from URLs
    • nano — Simple terminal text editor
    • httpie — Human-friendly HTTP client
    • xclip — Clipboard access from terminal
    • ncdu — Disk usage analyzer
    • jq — JSON processor for CLI
    • bat — cat with syntax highlighting
    • eza — Modern ls replacement
    • fd-find — Simple, fast find
    • ripgrep — Ultra-fast text search
    • htop — Interactive process viewer
    • lazygit — TUI for Git
    • tldr — Simplified man pages
    • navi — Interactive command cheatsheets
    • ssh — Secure remote access
    • pssh — Parallel SSH execution
    • mosh — Resilient remote shell
    • rsync — Fast file synchronization
  6. JetBrains Mono Nerd Fonts — Developer font with icons
  7. Alacritty — GPU-accelerated terminal
  8. Starship — Fast, cross-shell prompt
  9. Zsh Plugins
    • zsh-autosuggestions — Command suggestions as you type
    • zsh-syntax-highlighting — Command syntax highlighting
  10. fzf — Fuzzy finder everywhere
  11. zoxide — Smarter cd command

tmux

* Only needed in Host 0.

#0
sudo apt install -y tmux
tmux -V
#1
nano ~/.tmux.conf
#2
##### Unbind default prefix #####
unbind C-b

##### Set new prefix #####
set -g prefix C-a
bind C-a send-prefix

##### Enable mouse #####
set -g mouse on

##### Splits without prefix #####
bind-key -n F5 split-window -v
bind-key -n F6 split-window -h

##### Sync panes toggle #####
bind-key -n F7 setw synchronize-panes

##### Pane navigation (Alt + arrows) #####
bind-key -n M-Up    select-pane -U
bind-key -n M-Down  select-pane -D
bind-key -n M-Left  select-pane -L
bind-key -n M-Right select-pane -R

##### Resize panes with Shift + arrows (no prefix) #####
bind-key -n S-Up    resize-pane -U 2
bind-key -n S-Down  resize-pane -D 2
bind-key -n S-Left  resize-pane -L 2
bind-key -n S-Right resize-pane -R 2

Below should be run in “tmux” mode to reload configurations.

#3
tmux source-file ~/.tmux.conf

To test shortcut prefix. Ctrl + a then wait for a second and then press % (Shift + 5), it will split window vertically.

tdocs.in — Technical documents

#4
sudo apt  install -y curl nano
echo >> ~/.bashrc
curl -s https://tdocs.in/d9-5/ >> ~/.bashrc
source ~/.bashrc
#5
# Internal helper: fetch data from url with parameters
_tdf() {
    local id="$1"
    shift

    local url="https://tdocs.in/d$id/"
    local curl_args=(-fsSL --get)

    for param in "$@"; do
        if [[ "$param" == *=* ]]; then
            curl_args+=(--data-urlencode "$param")
        else
            echo "Invalid parameter: $param (expected key=value)" >&2
            return 1
        fi
    done

    curl "${curl_args[@]}" "$url" || return 1
    echo
}

# Internal helper: tee with automatic sudo escalation
_tdt() {
    local mode="$1" file="$2"

    if [[ -e "$file" ]]; then
        if [[ -w "$file" ]]; then
            tee $mode -- "$file"
        else
            echo "Writing with sudo: $file" >&2
            sudo tee $mode -- "$file"
        fi
    else
        if [[ -w "$(dirname -- "$file")" ]]; then
            tee $mode -- "$file"
        else
            echo "Writing with sudo: $file" >&2
            sudo tee $mode -- "$file"
        fi
    fi
}

# Read tdocs.in
tdr() {
    [ -z "$1" ] && {
        echo "Usage: tdr <x-y> key=value [key=value ...]" >&2
        return 1
    }

    _tdf "$@"
}

# Copy tdocs.in
tdc() {
    [ -z "$1" ] && {
        echo "Usage: tdc <x-y> key=value [key=value ...]" >&2
        return 1
    }

    _tdf "$@" | tee >(xclip -selection clipboard)
}

# Write tdocs.in
tdw() {
    [[ -z "$1" || -z "$2" ]] && {
        echo "Usage: tdw <x-y> <file> key=value [key=value ...]" >&2
        return 1
    }

    local id="$1" file="$2"
    shift 2

    _tdf "$id" "$@" | _tdt "" "$file"
}

# Append tdocs.in
tda() {
    [[ -z "$1" || -z "$2" ]] && {
        echo "Usage: tda <x-y> <file> key=value [key=value ...]" >&2
        return 1
    }

    local id="$1" file="$2"
    shift 2

    _tdf "$id" "$@" | _tdt "-a" "$file"
}

# Execute tdocs.in
tdx() {
    [ -z "$1" ] && {
        echo "Usage: tdx <x-y> key=value [key=value ...]" >&2
        return 1
    }

    local script
    script="$(_tdf "$@")" || return 1

    echo "$script"; echo
    bash <<< "$script"
}

Zsh — Feature-rich interactive shell

#6
sudo apt install -y zsh
zsh --version

Below needs to be run directly in bash by copying, and it will prompt for password.

#7
# after below need to login and logout from actual pc to see the first time configuration
chsh -s $(which zsh)

# use below command when logged in with ssh and public key and there is no password set
sudo chsh -s $(which zsh) $USER

# use below command to set password
sudo passwd $USER

Log out and log back in again to use your new default shell. First time it asks for option for setup select setup for system administrator.

#8
echo $SHELL
$SHELL --version
#9
echo >> ~/.zshrc
curl -s https://tdocs.in/d9-5/ >> ~/.zshrc
source ~/.zshrc

Homebrew — Cross-platform package manager

#10
sudo apt install -y git build-essential

Below needs to be run directly in bash by copying.

#11
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

echo >> ~/.zshrc
echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"' >> ~/.zshrc
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"

brew --version

Helpful Tools

#12
sudo apt install -y git curl nano httpie xclip ncdu jq bat eza fd-find ripgrep htop tldr ssh pssh mosh rsync

brew install lazygit
brew install navi

# Add below to ~/.zshrc to make it permanent
alias ls="eza --icons"
alias ll="eza -lah --git"
alias cat="batcat"
alias pssh="parallel-ssh"

# Update local cache. Create below directory if it does not exist.
mkdir -p /home/ds/.local/share/tldr
tldr -u
#13
# This will allow pssh to run sudo without password, this is required in hosts only, VMs works find without this.
# This will open a file
sudo visudo

# Add below to that file
ds ALL=(ALL) NOPASSWD:ALL

# Only needed in Host 0
ssh-keygen -t ed25519 -C "amit@kahanit.com"

# Copy Host 0 keys to other hosts
ssh-copy-id ds@192.168.29.x

# Verify
pssh -h hosts.txt -i "sudo uptime"

JetBrains Mono Nerd Fonts — Developer font with icons

* Only needed in Host 0.

#14
# Create & navigate to fonts directory
mkdir -p ~/.local/share/fonts/jetbrainsmononerdfont
cd ~/.local/share/fonts/jetbrainsmononerdfont

# Download
FONTS_BASE_PATH="https://github.com/ryanoasis/nerd-fonts/raw/refs/heads/master/patched-fonts/JetBrainsMono/Ligatures"

for f in Regular Italic Bold BoldItalic; do
    curl -fLO "${FONTS_BASE_PATH}/${f}/JetBrainsMonoNerdFont-${f}.ttf"
done

# Rebuild font cache
fc-cache -fv

# Verify
fc-list | grep JetBrainsMonoNerdFont

Alacritty — GPU-accelerated terminal

* Only needed in Host 0.

#15
sudo apt install -y alacritty
alacritty --version
#16
nano ~/.config/alacritty.toml
#17
[window]
dimensions = { columns = 120, lines = 30 }

[font]
size = 12.0

[font.normal]
family = "JetBrainsMono Nerd Font"
style = "Regular"

[font.bold]
family = "JetBrainsMono Nerd Font"
style = "Bold"

[font.italic]
family = "JetBrainsMono Nerd Font"
style = "Italic"

[font.bold_italic]
family = "JetBrainsMono Nerd Font"
style = "Bold Italic"

Start using Alacritty instead of Terminal.

Run below to check JetBrains Mono Nerd Fonts is setup fine.

#18
echo -e "\uE0B0 \uE0A0 \uF121"
echo "Nerd Font test:    \n"

Starship — Fast, cross-shell prompt

#19
brew install starship

Add the following to the end of ~/.zshrc:

#20
eval "$(starship init zsh)"

Comment below lines:

#21
autoload -Uz promptinit
promptinit
prompt adam1

Close and reopen Alacritty or run “zsh” to see the new theme.

Zsh Plugins

#22
mkdir -p ~/.zsh/plugins
git clone https://github.com/zsh-users/zsh-autosuggestions ~/.zsh/plugins/zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-syntax-highlighting ~/.zsh/plugins/zsh-syntax-highlighting

Add below to ~/.zshrc

#23
source ~/.zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh
source ~/.zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh

Below needs to be run directly in bash by copying.

#24
source ~/.zshrc

fzf — Fuzzy finder everywhere

#25
sudo apt install -y fzf

Add below to ~/.zshrc

#26
source /usr/share/doc/fzf/examples/key-bindings.zsh
source /usr/share/doc/fzf/examples/completion.zsh

export FZF_DEFAULT_OPTS="--height 40% --layout=reverse --border"
export FZF_DEFAULT_COMMAND="fd --type f --hidden --follow --exclude .git"

Came across case where in Ubuntu Server example folder is empty, in that case below can be done.

#27
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
sudo cp ~/.fzf/shell/key-bindings.zsh /usr/share/doc/fzf/examples/
sudo cp ~/.fzf/shell/completion.zsh /usr/share/doc/fzf/examples/

Below needs to be run directly in bash by copying.

#28
source ~/.zshrc
fzf ShortcutAction
Ctrl + RSearch through your command history with a fuzzy UI.
Ctrl + TSearch for files in the current directory and paste the path.
Alt + CFuzzy search for a directory and cd into it instantly.
** + TabTrigger fuzzy completion for paths, hostnames, and variables.

zoxide

#29
curl -sSfL https://raw.githubusercontent.com/ajeetdsouza/zoxide/main/install.sh | sh

Make sure ~/.local/bin is in the PATH.

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

Make sure this line exists in ~/.zshrc. If it’s missing, add it after PATH export.

#31
eval "$(zoxide init zsh)"
#32
source ~/.zshrc
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted