|
| 1 | +# `zsh` |
| 2 | + |
| 3 | +Installs Zsh and Zinit, sets Zsh as the default shell, and symlinks the dotfiles-managed config tree via `ZDOTDIR`. |
| 4 | + |
| 5 | +## Installs |
| 6 | + |
| 7 | +| CLI | macOS | Ubuntu | |
| 8 | +| ------- | ------ | ------------- | |
| 9 | +| `zsh` | `brew` | `apt` | |
| 10 | +| `zinit` | `brew` | `curl` script | |
| 11 | +| `curl` | `brew` | — | |
| 12 | + |
| 13 | +## Configures |
| 14 | + |
| 15 | +### Shell bootstrap |
| 16 | + |
| 17 | +- Default shell changed to Homebrew zsh (macOS) or `/usr/bin/zsh` (Ubuntu) |
| 18 | +- `~/.zshenv` → `.dotfiles/pkg/zsh/.zshenv` (manual symlink — the only file outside the repo) |
| 19 | + |
| 20 | +### `.zshenv` |
| 21 | + |
| 22 | +- Sets `ZDOTDIR=~/.dotfiles/pkg/zsh` so all subsequent config files are read directly from the repo |
| 23 | +- Exports XDG Base Directory vars: `XDG_CONFIG_HOME`, `XDG_DATA_HOME`, `XDG_STATE_HOME`, `XDG_CACHE_HOME`, `XDG_RUNTIME_DIR` |
| 24 | +- `EDITOR` set to Cursor, VS Code, or Sublime Text depending on `$TERM_PROGRAM` / `$IS_CURSOR` |
| 25 | +- Dracula color theme applied to `grep` output and Docker BuildKit (`$BUILDKIT_COLORS`) |
| 26 | +- Oh My Zsh behavior flags: `HYPHEN_INSENSITIVE`, `COMPLETION_WAITING_DOTS`, `ENABLE_CORRECTION`, `HIST_STAMPS` |
| 27 | + |
| 28 | +### `.zshrc` |
| 29 | + |
| 30 | +- Loads Zinit (from Homebrew prefix on macOS, `$XDG_DATA_HOME/zinit` on Ubuntu) |
| 31 | +- OMZ library snippets (no full OMZ install): `clipboard`, `completion`, `correction`, `directories`, `functions`, `git`, `history` |
| 32 | +- Tool integrations: carapace, direnv, mise, starship, zoxide |
| 33 | +- OMZ plugins: `colored-man-pages`, `colorize`, `command-not-found`, `gnu-utils`, `kubectl`, `macos`, `rbenv`, `thefuck` |
| 34 | +- Third-party plugins: `zsh-autosuggestions`, `zsh-syntax-highlighting`, `zsh-you-should-use` |
| 35 | +- Completions wired for: carapace, Docker, kubectl, gt, mise, 1Password CLI, Poetry, Starship |
| 36 | +- Alias groups: replacement (`rm`→`trash`, `cat`→`ccat`, `sed`→`gsed`), configs, docker, editors, kubectl, npm, pip, xattr |
| 37 | + |
| 38 | +### `.zfunc/` |
| 39 | + |
| 40 | +Custom autoloaded functions: |
| 41 | + |
| 42 | +| Function | Description | |
| 43 | +| ----------- | --------------------------------------------------------- | |
| 44 | +| `benchmark` | Times 10 interactive Zsh startups via `/usr/bin/time` | |
| 45 | +| `dns_purge` | Flushes DNS cache (`dscacheutil -flushcache`, macOS only) | |
| 46 | +| `fpath` | Prints `$FPATH` entries one per line | |
| 47 | +| `kill_port` | Kills the process bound to a given port via `pnpm dlx` | |
| 48 | +| `manpath` | Prints `$MANPATH` entries one per line | |
| 49 | +| `path` | Prints `$PATH` entries one per line | |
| 50 | +| `realcmd` | Resolves the real path of a command | |
| 51 | +| `reset_zsh` | Fixes `compaudit` permissions, clears caches, wipes Zinit | |
| 52 | + |
| 53 | +## Notes |
| 54 | + |
| 55 | +- On macOS, Homebrew zsh is added to `/etc/shells` before `chsh`; skipped in CI (`$CI` set). |
| 56 | +- On Ubuntu, an existing `~/.zshenv` is backed up to `~/.zshenv.bk` before symlinking. |
| 57 | +- `reset_zsh` fixes `compaudit` permission warnings, clears `~/.zcompdump*`, and deletes all compiled Zinit plugins — useful when completion breaks after a plugin update. |
| 58 | +- `kill_port <port>` delegates to `pnpm dlx kill-port`; requires `pnpm` to be available. |
| 59 | + |
| 60 | +## References |
| 61 | + |
| 62 | +- [Zinit - README](https://github.com/zdharma-continuum/zinit): Plugin manager used instead of a full Oh My Zsh install; explains `light-mode`, `lucid`, `wait`, and `snippet` loading modes. |
| 63 | +- [XDG Base Directory Specification](https://specifications.freedesktop.org/basedir-spec/latest/): Defines the env vars set in `.zshenv` that many tools use to locate config/cache/data directories. |
0 commit comments