# zsh setup

> Source: <https://gist.github.com/mluggy/c7224b485ea6300e7c187456b48bf31f>
> Published: 2026-06-02 06:46:46+00:00

| # ══════════════════════════════════════════════════════════════════════ | |
| # SETUP — install everything this file depends on | |
| # ══════════════════════════════════════════════════════════════════════ | |
| # Core tools (one line). Run once on a fresh machine: | |
| # | |
| # brew install starship fzf zoxide eza bat | |
| # | |
| # starship — the prompt | |
| # fzf — fuzzy finder (Ctrl+R history, Ctrl+T files) | |
| # zoxide — smart cd (`z <partial>` jumps to frequent dirs) | |
| # eza — modern ls (NOT exa, which is unmaintained) | |
| # bat — cat with syntax highlighting | |
| # ══════════════════════════════════════════════════════════════════════ | |
| # ── History ─────────────────────────────────────────────────────────── | |
| # 100k entries, shared live across tabs, no duplicates kept. | |
| # SHARE_HISTORY already implies incremental append, so INC_APPEND is dropped. | |
| HISTSIZE=100000 | |
| SAVEHIST=100000 | |
| HISTFILE=~/.zsh_history | |
| setopt SHARE_HISTORY # all open shells read/write the same history live | |
| setopt HIST_IGNORE_ALL_DUPS # drop older duplicate when a new dup is added | |
| setopt HIST_REDUCE_BLANKS # collapse superfluous whitespace before saving | |
| setopt HIST_FIND_NO_DUPS # skip dups when cycling through history search | |
| # ── Completions ─────────────────────────────────────────────────────── | |
| # Rebuild the completion dump at most once every 24h instead of every launch. | |
| # -C skips the security check and just loads the cached dump (the fast path). | |
| autoload -Uz compinit | |
| if [[ -n ~/.zcompdump(#qN.mh+24) ]]; then | |
| compinit # cache is stale (older than 24h) -> full rebuild | |
| else | |
| compinit -C # cache is fresh -> load without rescanning | |
| fi | |
| zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}' # case-insensitive matching | |
| zstyle ':completion:*' menu select # arrow-key menu selection | |
| # ── Cursor movement ─────────────────────────────────────────────────── | |
| # Option+Arrow jumps by word, Option+Backspace deletes a word. | |
| # Two keycode variants because terminals disagree on what they emit. | |
| bindkey '^[[1;3D' backward-word # Option+Left | |
| bindkey '^[[1;3C' forward-word # Option+Right | |
| bindkey '^[^?' backward-kill-word # Option+Backspace | |
| bindkey '^[[1;9D' backward-word # Alt+Left (some terminals) | |
| bindkey '^[[1;9C' forward-word # Alt+Right (some terminals) | |
| # ── Prompt and shell tooling ────────────────────────────────────────── | |
| # 2>/dev/null hides errors if a binary is missing, at the cost of silent | |
| # breakage. If your prompt ever looks wrong, drop the redirect to see why. | |
| eval "$(starship init zsh)" 2>/dev/null # prompt | |
| eval "$(fzf --zsh)" 2>/dev/null # Ctrl+R fuzzy history, Ctrl+T files | |
| eval "$(zoxide init zsh)" 2>/dev/null # smart cd: `z <partial>` | |
| # ── Aliases: navigation ────────────────────────────────────────────── | |
| alias ..='cd ..' | |
| alias ...='cd ../..' | |
| alias ....='cd ../../..' | |
| # ── Aliases: file listing (eza, colorful, dirs first) ──────────────── | |
| alias ls='eza --color --group-directories-first' | |
| alias la='eza --color -la --group-directories-first' | |
| alias ll='eza --color -l --group-directories-first' | |
| alias lt='eza --color --tree --level=2' | |
| # ── Aliases: git ───────────────────────────────────────────────────── | |
| alias gs='git status' | |
| alias gd='git diff' | |
| alias gds='git diff --staged' | |
| alias ga='git add' | |
| alias gaa='git add --all' | |
| alias gc='git commit' | |
| alias gcm='git commit -m' | |
| alias gp='git push' | |
| alias gpl='git pull' | |
| alias gl='git log --oneline --graph --all' | |
| alias gco='git checkout' | |
| alias gsw='git switch' | |
| alias gb='git branch' | |
| alias gst='git stash' | |
| alias gstp='git stash pop' | |
| # ── Aliases: bat (syntax-highlighted cat) ──────────────────────────── | |
| alias c='bat --style=plain' | |
| alias b='bat' | |
| # ── Editor ─────────────────────────────────────────────────────────── | |
| export EDITOR="nano" | |
| export VISUAL="nano" | |
| # ── Locale ─────────────────────────────────────────────────────────── | |
| export LANG=en_US.UTF-8 | |
| # ── Quality of life ────────────────────────────────────────────────── | |
| setopt AUTO_CD # type a directory name to cd into it | |
| alias path='echo $PATH | tr ":" "\n"' # print PATH one entry per line | |
| alias reload='source ~/.zshrc' # re-source after edits | |
| alias hosts='sudo nano /etc/hosts' # edit the hosts file |
