My ZSH aliases and functions for developer productivity

A curated collection of ZSH aliases and custom functions that streamline daily development workflows, from AI-powered Git commits to fuzzy file searching and modern CLI tool replacements.

0 views
--- likes

Over the years I've built up a collection of aliases and functions that eliminate repetitive typing and speed up my most common workflows. Rather than memorizing long commands or scrolling through history, I use short mnemonics that map to the tools and patterns I use daily.

This post shares my full alias configuration—organized by category—along with custom functions that add fuzzy finding, intelligent search, and workflow automation to the shell.

The philosophy is simple: optimize for the commands you run most often, embrace modern CLI alternatives, and automate the annoying parts (like crafting commit messages or cleaning up Docker cruft).

Development Tools

These aliases cover my daily development workflow—opening editors, running Git commands, and managing project dependencies:

# Development Tools
alias ghc='gh copilot suggest -t shell' # Install extension first: gh extension install github/gh-copilot
alias {c,v,code}='open -a "Visual Studio Code"'
alias w='open -a "Windsurf"'
alias copy="tr -d '\n' | pbcopy"
alias g='git'
alias pj='projen'
alias reload='exec zsh'

Highlights:

  • ghc - GitHub Copilot CLI for shell command suggestions (requires gh extension install github/gh-copilot)
  • c, v, code - All open VS Code (multiple aliases for muscle memory)
  • w - Opens Windsurf editor
  • copy - Strips newlines and copies to clipboard
  • g - Shorthand for Git
  • pj - Quick access to Projen for AWS CDK project management
  • reload - Restart ZSH session without closing the terminal

Package Management

Managing dependencies across Python, npm, and Homebrew:

# Package Management
alias brewdeps='brew list --formula | xargs brew deps --graph --dot'
 
## Python/uv
alias uvp='uv pip'
alias uvv='uv venv --python $(python --version 2>&1 | sed "s/Python //")'
alias uvc='uv pip freeze | rg -v "^(packaging|setuptools)==" | xargs uv pip uninstall'
alias uvd='uv pip install boto3 \
    types-boto3-full \
    botocore \
    pytest \
    setuptools \
    --upgrade'
 
## NPM
alias npmu='npm update'
alias npmug='npm update -g'
alias npmc="npm ls -p --depth=0 | awk-modules | rg -v 'npm' | xargs npm rm && npm cache clean --force"
alias npmcg="npm ls -gp --depth=0 | awk-modules | rg -v 'npm' | xargs npm -g rm && npm cache clean --force"

Highlights:

  • brewdeps - Visualize Homebrew dependency graph in DOT format
  • uvp - Shorthand for uv pip (uv is a fast Python package installer)
  • uvv - Create virtual environment using current Python version
  • uvc - Clean virtual environment by uninstalling all packages except core tools
  • uvd - Install my default Python development stack (AWS SDK, type stubs, testing)
  • npmc/npmcg - Clean local/global npm packages and cache

Modern CLI Replacements

I replace traditional Unix tools with modern, faster alternatives that have better defaults:

# Modern CLI Replacements
alias cat='bat'
alias df='duf'
alias du='dust'
alias find='fd'
alias grep='rg'
alias jq='jaq'
alias ping='gping'
alias ps='procs --sortd cpu'
alias top='btm -b'

These tools provide syntax highlighting, better output formatting, and improved performance:

  • catbat - Syntax highlighting and Git integration
  • dfduf - Disk usage with colored output
  • dudust - Intuitive disk usage visualization
  • findfd - Faster, user-friendly alternative
  • greprg - Blazing fast search (ripgrep)
  • jqjaq - Faster JSON processor
  • pinggping - Graph ping times
  • psprocs - Modern process viewer sorted by CPU
  • topbtm - Bottom, a graphical process/system monitor

File Operations

Modern file listing with icons and Git status:

# File Operations
alias ll='eza -alh --icons --group-directories-first'
alias ls='eza --icons --group-directories-first'

eza is a modern replacement for ls with colors, icons, Git integration, and sensible defaults.

Network Tools

Quick access to network information:

# Network Tools
alias ifactive="ifconfig | pcregrep -M -o '^[^\t:]+:([^\n]|\n\t)*status: active'"
alias ip="curl -s icanhazip.com | tr -d '%'"
alias localip='ipconfig getifaddr en0'

Highlights:

  • ifactive - Show only active network interfaces
  • ip - Get your public IP address
  • localip - Get your local network IP (macOS)

Path Management

Visualize your PATH and FPATH variables in a readable format:

# Path Management
alias path='echo -e ${PATH//:/\\n}'
alias fpath='echo -e ${FPATH//:/\\n}'

Instead of seeing a colon-separated mess, these aliases display one path per line.

Fuzzy Finding

Quick access to custom fuzzy finding functions (detailed in the Functions section below):

# Fuzzy Finding
alias fff='fuzzy-file-finder'
alias fif='fuzzy-in-file-search'

System Tools

Miscellaneous system utilities:

# System Tools
alias update='topgrade'
alias weather='clear && curl wttr.in'
alias week='date +%V'
alias icloud='builtin cd ~/Library/Mobile\ Documents/com\~apple\~CloudDocs/'

Highlights:

  • update - Update everything with topgrade
  • weather - Show weather forecast in terminal via wttr.in
  • week - Display current week number
  • icloud - Navigate to iCloud Drive folder

Custom Functions

Beyond simple aliases, I use functions for more complex workflows. These provide intelligent search, cleanup automation, and development utilities.

Logging Utility

# function to add timestamps to log messages
log() {
    local level="$1"
    local message="$2"
    echo "[$(date +'%d-%m-%Y %H:%M:%S')] [$level] $message"
}

Usage:

log INFO "Starting deployment"
# Output: [28-10-2025 14:30:45] [INFO] Starting deployment

ZSH Cleanup

# function to clean up zsh-related caches
function zsh-cleanup() {
    rm -rf "$XDG_CACHE_HOME" &&
    rm -rf "$HOME/.zcompdump" &&
    rm -rf "$HOME/.*.zwc"
}

Removes ZSH completion caches and compiled files when things get corrupted.

ZSH Startup Timer

# function to gauge zsh's startup time
function zsh-timer() {
  shell=${1-$SHELL}
  for i in $(seq 1 10); do /usr/bin/time $shell -i -c exit; done
}

Benchmark shell startup time by running 10 iterations. Useful for profiling configuration changes.

Docker Cleanup

# Docker cleanup function
docker-clean() {
    docker container prune -f
    docker image prune -f
    docker network prune -f
    docker volume prune -f
}

One command to clean up all Docker resources (containers, images, networks, volumes).

NPM Module Path Parser

awk-modules() {
    awk -F/node_modules/ '{print $2}'
}

Helper function used by npmc and npmcg aliases to extract module names from npm path output.

Fuzzy File Finder

# Helper function for common FZF options
_fzf_with_opts() {
    FZF_DEFAULT_OPTS="$FZF_DEFAULT_OPTS $FZF_CTRL_T_OPTS --bind 'backspace:backward-delete-char/eof'" fzf "$@"
}
 
fuzzy-file-finder() {
  local dir args result
  args=()
  # Collect all given arguments into an array unless it's a directory
  for arg in "$@"; do
    [[ -d "$arg" ]] && dir="$arg" || args+=("$arg")
  done
 
  # Use specified directory, if available, otherwise default to current directory
  result=$(fd "${args[@]}" "${dir:-.}" | _fzf_with_opts)
 
  # If a file or directory was selected, print it to the command line
  [[ -n "$result" ]] && print -z "$result"
}

Usage:

fff              # Search all files in current directory
fff src          # Search files in src/ directory
fff --extension js  # Search only JavaScript files

Uses fd for fast file discovery and fzf for interactive selection. The selected file appears on your command line ready to use.

fuzzy-in-file-search() {
  local initial_query="" rg_smart_case="--smart-case" args=()
 
  # If arguments are provided, process them
  if [[ $# -gt 0 ]]; then
    initial_query="$1"
    shift
    for arg in "$@"; do
      [[ "$arg" == "--ignore-case" ]] && rg_smart_case="--ignore-case" || args+=("$arg")
    done
  fi
 
  # Construct the rg command
  local rg_command="rg --files-with-matches --no-messages $rg_smart_case ${args[*]}"
 
  # Use fzf with dynamic search
  local result=$(FZF_DEFAULT_OPTS="$FZF_DEFAULT_OPTS $FZF_CTRL_T_OPTS --bind 'backspace:backward-delete-char/eof'" \
      fzf --query "$initial_query" \
      --phony \
      --disabled \
      --bind "change:reload:$rg_command -F {q} || true" \
      --bind "start:reload:$rg_command -F {q} || true" \
      --preview "rg --pretty --color always --context 10 --max-columns 200 $rg_smart_case -F {q} {1} ${args[*]}")
 
  # If a file was selected, print it to the command line
  [[ -n "$result" ]] && print -z "$result"
}

Usage:

fif TODO                    # Search for "TODO" in all files
fif "bug fix" --ignore-case # Case-insensitive search

Live-updating search that shows preview context with syntax highlighting. As you type, results update in real-time using ripgrep.

h() {
    local search_term="$*" selected entry
 
    if [[ -z "$search_term" ]]; then
        selected=$(history 0 | FZF_DEFAULT_OPTS="$FZF_DEFAULT_OPTS $FZF_CTRL_R_OPTS --bind 'backspace:backward-delete-char/eof'" fzf --tac --no-sort)
        entry=$(echo "$selected" | rg -o '^ *[0-9]+ *(.+)$' -r '$1')
    else
        selected=$(history -E 1 | rg -i "$search_term" | FZF_DEFAULT_OPTS="$FZF_DEFAULT_OPTS $FZF_CTRL_R_OPTS" fzf --tac --no-sort)
        entry=$(echo "$selected" | rg -o '^ *[0-9]+ *(.+)$' -r '$1')
    fi
 
    [[ -n "$entry" ]] && print -z "$entry"
}

Usage:

h           # Browse all history
h docker    # Search history for "docker" commands

Fuzzy history search with optional pre-filtering. Selected command appears on your command line.

Most Used Commands

muc() {
    # Lists the most used commands in the terminal
    history 0 | \
    awk '
        {CMD[$2]++; count++}
        END {
            for (a in CMD)
                printf "%d %.2f%% %s\n", CMD[a], CMD[a]/count*100, a
        }
    ' | \
    rg -v "./" | \
    sort -nr | \
    head -n30 | \
    nl
}

Usage:

muc
# Output:
#  1  450  15.23%  git
#  2  320  10.84%  ls
#  3  287   9.72%  cd
# ...

Analyze your shell history to see which commands you use most frequently. Great for identifying candidates for new aliases.

Telnet via cURL

telnet() {
    curl -v telnet://"$1":"$2"
}

Usage:

telnet example.com 80

Modern telnet replacement using cURL for debugging network connections.

Enhanced Tree View

tree() {
    local level=${1:-1}  # Default level if none is provided
    eza --tree --level="$level" -I node_modules --git-ignore
}

Usage:

tree      # Show directory tree (depth 1)
tree 3    # Show directory tree (depth 3)

Uses eza for a colorful tree view that respects .gitignore and excludes node_modules.

Integration with Main Config

These aliases and functions should be added to your .zshrc file, ideally after loading plugins but before any interactive prompt customization.

If you're using my ZSH configuration, I recommend creating a separate file ~/.config/zsh/functions/alias.zsh with all your aliases and functions (including the ones from this post if you want), then loading it via Sheldon with deferred loading for optimal performance.

See the Sheldon Plugin Manager section in my ZSH config post for the complete plugin configuration.

Prerequisites

To use all these aliases and functions, install the required tools:

brew install \
    bat \
    bottom \
    duf \
    dust \
    eza \
    fd \
    fzf \
    gping \
    jaq \
    procs \
    ripgrep \
    topgrade \
    uv
 
# GitHub Copilot CLI
gh extension install github/gh-copilot

Conclusion

These aliases and functions represent years of iteration to reduce friction in daily development work. The key principles:

  1. Short mnemonics for frequent operations - g for git, c for code, ll for detailed listing
  2. Modern tool defaults - Replace legacy Unix tools with faster, more user-friendly alternatives
  3. Fuzzy finding everywhere - Use fzf to make searching interactive and discoverable
  4. Automate the annoying parts - One-command cleanup, automated updates, intelligent search

Start with the aliases you'll use most (likely the Modern CLI Replacements and Development Tools), then gradually adopt the functions as you encounter workflows they solve.

For the full ZSH configuration these integrate with, see my ZSH config built for speed post.