Zsh shell configuration using Znap plugin manager, Starship prompt, and extensive customizations for a productive terminal environment.
~/.zshenv # Environment variables (always sourced)
~/.zshrc # Interactive shell configuration
~/.config/zsh/ # Additional configuration files
├── functions/ # Custom shell functions
└── completion/ # Custom completions
graph TD
A[Terminal Start] --> B{Login Shell?}
B -->|Yes| C[/etc/zshenv]
B -->|No| C
C --> D[~/.zshenv]
D --> E{Login Shell?}
E -->|Yes| F[/etc/zprofile]
E -->|No| H
F --> G[~/.zprofile]
G --> H{Interactive?}
H -->|Yes| I[/etc/zshrc]
H -->|No| L
I --> J[~/.zshrc]
J --> K{Login Shell?}
K -->|Yes| L[/etc/zlogin]
K -->|No| M[Shell Ready]
L --> M
~/.zshenvSourced for all Zsh instances. Keep minimal for performance.
Current Contents:
# This file is sourced by all instances of Zsh, and thus should be kept as
# small as possible and should only define environment variables.
Purpose:
~/.zshrcMain configuration for interactive shells.
Structure:
Installation Path: ~/znap/zsh-snap
Core Commands:
| Command | Description | Example |
|———|————-|———|
| znap install | Install a plugin | znap install ohmyzsh/ohmyzsh |
| znap source | Source a plugin | znap source zsh-users/zsh-autosuggestions |
| znap eval | Evaluate and cache command | znap eval starship 'starship init zsh' |
| znap pull | Update plugins | znap pull |
Loaded Plugins:
ohmyzsh/ohmyzsh - Framework for configurationszsh-users/zsh-autosuggestions - Fish-like suggestionszsh-users/zsh-completions - Additional completionsmarlonrichert/zsh-autocomplete - Real-time completionsDevelopment Tools:
| Variable | Purpose | Value |
|———-|———|——-|
| EDITOR | Default text editor | code --wait |
| VISUAL | Visual editor | code --wait |
| PAGER | Output pager | less |
Language Environments:
| Variable | Purpose | Path |
|———-|———|——|
| JAVA_HOME | Java installation | /opt/homebrew/opt/openjdk |
| GOPATH | Go workspace | $HOME/go |
| DVM_DIR | Deno version manager | $HOME/.dvm |
Security:
| Variable | Purpose | Value |
|———-|———|——-|
| GPG_TTY | GPG terminal | $(tty) |
| SSH_AUTH_SOCK | SSH agent socket | GPG agent socket |
Path additions in order:
$HOME/bin # Personal scripts
$HOME/.local/bin # User installations
/opt/homebrew/bin # Homebrew (Apple Silicon)
/usr/local/bin # Traditional installs
$GOPATH/bin # Go binaries
$HOME/.cargo/bin # Rust binaries
$DVM_DIR/bin # Deno versions
$HOME/.claude/local # Claude CLI
$HOME/.dotnet/tools # .NET tools
File Management:
| Alias | Command | Description |
|——-|———|————-|
| ll | ls -la | Long listing with hidden files |
| la | ls -A | List all except . and .. |
| l | ls -CF | Classify file types |
Directory Navigation:
| Alias | Command | Description |
|——-|———|————-|
| .. | cd .. | Parent directory |
| ... | cd ../.. | Two levels up |
| .... | cd ../../.. | Three levels up |
Git Shortcuts:
| Alias | Command | Description |
|——-|———|————-|
| g | git | Git shorthand |
| gst | git status | Status shorthand |
| gco | git checkout | Checkout shorthand |
Development:
| Alias | Command | Description |
|——-|———|————-|
| py | python3 | Python 3 |
| pip | pip3 | Pip 3 |
| serve | python3 -m http.server | Simple HTTP server |
Custom functions are stored in ~/.config/zsh/functions/:
Available Functions:
mkcd - Create directory and cd into itextract - Universal archive extractorbackup - Create timestamped backupsfzf-git-branch - Fuzzy find git branchesExample Function:
# mkcd - Make directory and change to it
mkcd() {
mkdir -p "$1" && cd "$1"
}
Initialization:
autoload -Uz compinit && compinit
Settings:
Custom Completions:
Located in ~/.config/zsh/completion/
Navigation:
| Key | Action |
|—–|——–|
| Ctrl+A | Beginning of line |
| Ctrl+E | End of line |
| Ctrl+W | Delete word backward |
| Ctrl+U | Delete to beginning |
History:
| Key | Action |
|—–|——–|
| Ctrl+R | Reverse history search |
| Ctrl+P | Previous command |
| Ctrl+N | Next command |
| ↑/↓ | History with prefix search |
Configuration: ~/.config/starship.toml
Features:
Customization Example:
[directory]
truncation_length = 3
truncate_to_repo = false
[git_branch]
symbol = "🌱 "
truncation_length = 20
Commands evaluated on first use:
znap eval rbenv 'rbenv init -'
znap eval pyenv 'pyenv init -'
Zsh compiles scripts to .zwc files for faster loading:
zcompile ~/.zshrc
zcompile ~/.config/zsh/functions/*
# Add to beginning of .zshrc
zmodload zsh/zprof
# Add to end of .zshrc
zprof
# Start shell with verbose output
zsh -xv
# Print each file as it's sourced
export ZSH_TRACE=1
case "$OSTYPE" in
darwin*) # macOS specific
export HOMEBREW_PREFIX="/opt/homebrew"
;;
linux*) # Linux specific
export HOMEBREW_PREFIX="/home/linuxbrew/.linuxbrew"
;;
esac
# Load machine-specific settings
[[ -f ~/.zshrc.local ]] && source ~/.zshrc.local