Skip to content

Command Line Setup

Published: February 14, 2026 · Last edited: February 24, 2026

A balanced approach to terminal configuration that reduces cognitive load while maintaining security.

Core Philosophy

  • Visual clarity over minimalism
  • Helpful defaults that prevent mistakes
  • Clear confirmation for destructive actions
  • Contextual information always visible
  • Reduced decision fatigue

1. Shell Configuration (Bash/Zsh)

  • Bash file: ~/.bash
  • Zsh configuration file: ~/.zshrc

This documentation will default to ~/.zshrc

Essential Aliases - Add to ~/.zshrc

bash
# Safe defaults - prevent accidents
alias rm='rm -i'                    # Always confirm before deleting
alias mv='mv -i'                    # Always confirm before overwriting
alias cp='cp -i'                    # Always confirm before overwriting
alias mkdir='mkdir -pv'             # Create parent dirs, show what's created

# Clear visual feedback
export CLICOLOR=1
export LSCOLORS=GxFxCxDxBxegedabagaced
alias ls='ls -Gh'
alias ll='ls -lAh'
alias la='ls -A'

# Git shortcuts with visibility or check [[git-setup.md]]
alias gs='git status'
alias gd='git diff'
alias gl='git log --oneline --graph --decorate --all -10'
alias gll='git log --oneline --graph --decorate --all'
alias gb='git branch -v'

# Directory navigation
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
alias ~='cd ~'
alias -- -='cd -'                   # Go back to previous directory
alias workspace='cd ~/workspace'    # Go to git workspace directory

# Quick clarity
alias path='echo -e ${PATH//:/\\n}'
alias now='date +"%Y-%m-%d %H:%M:%S"'
alias ports='lsof -iTCP -sTCP:LISTEN -n -P' # Check [[../guides/listening-ports.md]] for more details

# Process management
alias psgrep='ps aux | grep -v grep | grep -i -e VSZ -e'
alias meminfo='free -m -l -t'
alias psmem='ps auxf | sort -nr -k 4 | head -10'
alias pscpu='ps auxf | sort -nr -k 3 | head -10'

Helper Functions - Add to ~/.bashrc or ~/.zshrc

bash
# Confirm before dangerous operations
confirm() {
    read -r -p "${1:-Are you sure? [y/N]} " response
    case "$response" in
        [yY][eE][sS]|[yY]) 
            true
            ;;
        *)
            false
            ;;
    esac
}

# Safe force remove - still asks first
rmf() {
    if confirm "Delete $* permanently? [y/N]"; then
        rm -rf "$@"
    else
        echo "Cancelled."
    fi
}

# Make and cd into directory
mkcd() {
    mkdir -p "$1" && cd "$1"
}

# Extract any archive type
extract() {
    if [ -f "$1" ]; then
        case "$1" in
            *.tar.bz2)   tar xjf "$1"     ;;
            *.tar.gz)    tar xzf "$1"     ;;
            *.bz2)       bunzip2 "$1"     ;;
            *.rar)       unrar x "$1"     ;;
            *.gz)        gunzip "$1"      ;;
            *.tar)       tar xf "$1"      ;;
            *.tbz2)      tar xjf "$1"     ;;
            *.tgz)       tar xzf "$1"     ;;
            *.zip)       unzip "$1"       ;;
            *.Z)         uncompress "$1"  ;;
            *.7z)        7z x "$1"        ;;
            *)           echo "'$1' cannot be extracted" ;;
        esac
    else
        echo "'$1' is not a valid file"
    fi
}

# Show directory size in human readable format
dsize() {
    du -sh "${1:-.}"
}

# Quick backup of file
backup() {
    cp "$1" "$1.backup-$(date +%Y%m%d-%H%M%)"
    ## [bug] the echoed filename may be wrong if one minute has passed since the backup was created, but it's a minor issue
    echo "💾 Backup file created: $1.backup-$(date +%Y%m%d-%H%M%)"
}
alias bckp='backup'
alias bckup='backup'

# Find file by name
ff() {
    find . -type f -iname "*$1*"
}

# Find directory by name
fd() {
    find . -type d -iname "*$1*"
}

2. Visual Prompt Configuration

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

Create ~/.config/starship.toml:

toml
# Timeout for commands (prevents hanging)
command_timeout = 1000

# Format - keep it clean but informative
format = """
[┌─](bold green) $directory$git_branch$git_status$python$nodejs$rust$golang
[└─](bold green) $character"""

[character]
success_symbol = "[➜](bold green)"
error_symbol = "[✗](bold red)"

[directory]
truncation_length = 3
truncate_to_repo = true
style = "bold cyan"

[git_branch]
symbol = " "
style = "bold purple"

[git_status]
conflicted = "⚔️ "
ahead = "⬆️ "
behind = "⬇️ "
diverged = "🔱 "
untracked = "📝 "
stashed = "📦 "
modified = "📝 "
staged = "✅ "
renamed = "➡️ "
deleted = "🗑️ "

[python]
symbol = " "
style = "yellow"

[nodejs]
symbol = " "
style = "green"

[rust]
symbol = " "
style = "red"

[golang]
symbol = " "
style = "cyan"

3. Command History Configuration

Add to ~/.bashrc:

bash
# Limited history
export HISTSIZE=50000
export HISTFILESIZE=100000

# Avoid duplicates and commands starting with space
export HISTCONTROL=ignoreboth:erasedups

# Timestamp in history
export HISTTIMEFORMAT="%Y-%m-%d %H:%M:%S  "

# Append to history, don't overwrite
shopt -s histappend

# Save multi-line commands as one
shopt -s cmdhist

# Update LINES and COLUMNS after each command
shopt -s checkwinsize

4. Useful Environment Variables

bash
# Better less behavior
export LESS='-R -M -i -j10 -#4'

# Colored man pages
export LESS_TERMCAP_mb=$'\e[1;32m'
export LESS_TERMCAP_md=$'\e[1;32m'
export LESS_TERMCAP_me=$'\e[0m'
export LESS_TERMCAP_se=$'\e[0m'
export LESS_TERMCAP_so=$'\e[01;33m'
export LESS_TERMCAP_ue=$'\e[0m'
export LESS_TERMCAP_us=$'\e[1;4;31m'

# Set default editor
export EDITOR=nano  # or vim if you prefer
export VISUAL=$EDITOR

# Enable colored output for common tools
export CLICOLOR=1
export GREP_OPTIONS='--color=auto'

5. Security-Focused Settings

bash
# File creation mask - files created with secure permissions
umask 027  # Owner: rwx, Group: r-x, Others: none

# Don't save sensitive commands to history
export HISTIGNORE="*sudo -S*:*password*:*passwd*:*aws_secret*:*api_key*"

# Auto-logout after inactivity (30 minutes)
export TMOUT=1800

# Secure PATH - prevent executing from current directory
export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:$HOME/bin"

6. Essential Tools to Install

For Better UX:

bash
# Improved versions of core utilities
sudo apt install bat      # Better 'cat' with syntax highlighting
sudo apt install exa      # Better 'ls' with more info
sudo apt install ripgrep  # Faster 'grep'
sudo apt install fd-find  # Faster 'find'
sudo apt install fzf      # Fuzzy finder for history/files
sudo apt install tldr     # Simplified man pages
sudo apt install ncdu     # Visual disk usage

Aliases for new tools:

bash
alias cat='bat --style=plain --paging=never'
alias ls='exa --icons --group-directories-first'
alias ll='exa -l --icons --group-directories-first -h'
alias tree='exa --tree --icons'
alias grep='rg'
alias find='fd'

7. FZF Configuration (Fuzzy Finding)

Add to ~/.bashrc:

bash
# FZF for command history search
[ -f ~/.fzf.bash ] && source ~/.fzf.bash

# Ctrl+R: Search command history
# Ctrl+T: Search files
# Alt+C: Search directories

# Better FZF defaults
export FZF_DEFAULT_OPTS='
  --height 40% 
  --layout=reverse 
  --border 
  --preview "bat --style=numbers --color=always {}"
  --color=fg:#f8f8f2,bg:#282a36,hl:#bd93f9
  --color=fg+:#f8f8f2,bg+:#44475a,hl+:#bd93f9
  --color=info:#ffb86c,prompt:#50fa7b,pointer:#ff79c6
  --color=marker:#ff79c6,spinner:#ffb86c,header:#6272a4'

8. Git Configuration for Clarity

bash
# Global git settings
git config --global color.ui auto
git config --global color.status auto
git config --global color.branch auto

# Better diff
git config --global core.pager 'less -R'

# Aliases
git config --global alias.st 'status -sb'
git config --global alias.co checkout
git config --global alias.br 'branch -v'
git config --global alias.unstage 'reset HEAD --'
git config --global alias.last 'log -1 HEAD'
git config --global alias.visual 'log --oneline --graph --decorate --all'

9. Daily Workflow Helpers

Create ~/bin/check-status.sh:

bash
#!/bin/bash
# Quick morning status check

echo "=== System Status ==="
echo "Date: $(date)"
echo "Uptime: $(uptime -p)"
echo ""

echo "=== Disk Usage ==="
df -h / /home 2>/dev/null | grep -v tmpfs
echo ""

echo "=== Git Repos Needing Attention ==="
for dir in ~/projects/*/; do
    if [ -d "$dir/.git" ]; then
        cd "$dir"
        if [[ -n $(git status -s) ]]; then
            echo "📝 $(basename "$dir"): Uncommitted changes"
        fi
        if [[ $(git rev-list --count @{u}..HEAD 2>/dev/null) -gt 0 ]]; then
            echo "⬆️  $(basename "$dir"): Unpushed commits"
        fi
    fi
done
echo ""

echo "=== TODO Reminder ==="
[ -f ~/TODO.txt ] && head -5 ~/TODO.txt || echo "No TODO file found"

Make it executable: chmod +x ~/bin/check-status.sh

10. Command Line Cheatsheet

Create ~/bin/help.sh:

bash
#!/bin/bash
# Quick reference for common tasks

cat << 'EOF'
🚀 COMMAND LINE CHEATSHEET

📁 NAVIGATION
  ..          Go up one directory
  -           Go to previous directory
  mkcd NAME   Make directory and enter it
  ll          List all files with details

🔍 FINDING STUFF
  ff NAME     Find file by name
  fd NAME     Find directory by name
  Ctrl+R      Search command history (fuzzy)

📝 FILE OPERATIONS
  backup FILE Create timestamped backup
  extract FILE Extract any archive
  dsize [DIR] Show directory sizes

🔐 SAFE OPERATIONS (will ask for confirmation)
  rm          Remove (asks first)
  rmf         Remove recursively (asks first)
  mv          Move (asks before overwrite)
  cp          Copy (asks before overwrite)

🌳 GIT SHORTCUTS
  gs          git status
  gd          git diff
  gl          git log (last 10, visual)
  gb          git branch list

🛠️ SYSTEM
  ports       Show open ports
  psmem       Top 10 memory hogs
  pscpu       Top 10 CPU hogs

❓ HELP
  tldr CMD    Simple examples for command
  help        This cheatsheet
EOF

Make it executable: chmod +x ~/bin/help.sh Add alias: alias help='~/bin/help.sh'

Usage Tips

  1. Start small: Don't enable everything at once. Add aliases as you need them.
  2. Use the cheatsheet: Type help when you forget commands
  3. Visual cues matter: Colors and icons reduce mental load
  4. Confirmation dialogs: Better to confirm than regret
  5. Keep history searchable: Ctrl+R is your friend
  6. Morning ritual: Run check-status.sh to orient yourself

Customization

This setup is a starting point. Modify based on:

  • Your most common mistakes (add confirmations)
  • Your most common tasks (add shortcuts)
  • Your visual preferences (adjust colors)
  • Your security requirements (adjust permissions)

Remember: The goal is reduced cognitive load, not perfection.

  • Vim Setup — The editor that pairs with your shell
  • Git Setup — Version control configuration that builds on your shell aliases