Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions .chezmoiexternal.toml.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Externally-sourced assets, fetched and refreshed by chezmoi directly.
# Replaces the run_onchange_install-*-themes scripts and the navi-cheats clone
# logic — declarative, cached, with a built-in refresh interval.
#
# Post-fetch steps that can't be expressed here stay as tiny run_onchange
# scripts keyed on this file's hash: bat cache rebuild, k9s skin bootstrap.

{{- $refresh := "168h" }}

# ── navi community cheatsheets ──────────────────────────────────────────────
{{ if and .alt_tools (not (has "navi" .machine_excludes)) -}}
{{ range $repo := list "denisidoro/cheats" "denisidoro/navi-tldr-pages" "tg-z/navi-cheats" -}}
[".local/share/navi/cheats/{{ $repo | replace "/" "__" }}"]
type = "git-repo"
url = "https://github.com/{{ $repo }}.git"
refreshPeriod = "{{ $refresh }}"
clone = { args = ["--depth=1"] }
pull = { args = ["--ff-only"] }
{{ end -}}
{{ if .kubernetes -}}
[".local/share/navi/cheats/tsologub__navi-cheats"]
type = "git-repo"
url = "https://github.com/tsologub/navi-cheats.git"
refreshPeriod = "{{ $refresh }}"
clone = { args = ["--depth=1"] }
pull = { args = ["--ff-only"] }
{{ end -}}
{{ end -}}

# ── bat: Catppuccin themes (rebuild cache in run_onchange_bat-cache) ────────
{{ if and .alt_tools (not (has "bat" .machine_excludes)) -}}
{{ range $flavor := list "Macchiato" "Latte" -}}
[".config/bat/themes/Catppuccin {{ $flavor }}.tmTheme"]
type = "file"
url = "https://raw.githubusercontent.com/catppuccin/bat/main/themes/Catppuccin%20{{ $flavor }}.tmTheme"
refreshPeriod = "{{ $refresh }}"
{{ end -}}
{{ end -}}

# ── btop: Catppuccin themes (always installed) ─────────────────────────────
{{ range $flavor := list "latte" "frappe" "macchiato" "mocha" -}}
[".config/btop/themes/catppuccin_{{ $flavor }}.theme"]
type = "file"
url = "https://raw.githubusercontent.com/catppuccin/btop/main/themes/catppuccin_{{ $flavor }}.theme"
refreshPeriod = "{{ $refresh }}"
{{ end -}}

# ── fresh editor: Catppuccin themes ───────────────────────────────────────
{{ if eq .editor "fresh" -}}
{{ range $flavor := list "latte" "frappe" "macchiato" "mocha" -}}
[".config/fresh/themes/catppuccin-{{ $flavor }}.json"]
type = "file"
url = "https://raw.githubusercontent.com/milon/catppuccin-fresh/master/catppuccin-{{ $flavor }}.json"
refreshPeriod = "{{ $refresh }}"
{{ end -}}
{{ end -}}

# ── k9s: Catppuccin skins (skin selection in sync-theme / k9s-skin bootstrap)
{{ if .kubernetes -}}
[".config/k9s/skins"]
type = "archive"
url = "https://github.com/catppuccin/k9s/archive/main.tar.gz"
refreshPeriod = "{{ $refresh }}"
stripComponents = 2
include = ["k9s-main/dist/**"]
{{ end -}}
3 changes: 0 additions & 3 deletions .chezmoiignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ README.md
UNLICENSE
install.sh

# Data consumed by dots-setup directly from the source tree — not deployed
.local/share/dots-setup

# NOTE: patterns match TARGET paths (the deployed ~/… path), not source
# filenames — so no dot_ prefix and no .tmpl/executable_/run_once_ attributes.

Expand Down
15 changes: 15 additions & 0 deletions .chezmoiscripts/run_onchange_bat-cache.sh.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
# Rebuilds bat's theme cache after .chezmoiexternal fetches the Catppuccin
# .tmTheme files — bat won't see new theme files until the cache is rebuilt.
# .chezmoiexternal hash: {{ include ".chezmoiexternal.toml.tmpl" | sha256sum }}

set -euo pipefail

export PATH="/opt/homebrew/bin:$PATH"

command -v bat &>/dev/null || exit 0

# Run from / — bat misreads 'cache' as a filename when a dir named 'cache'
# exists in the CWD (sharkdp/bat#1726).
(cd / && bat cache --build)
echo "✅ bat theme cache rebuilt."
34 changes: 0 additions & 34 deletions .chezmoiscripts/run_onchange_install-bat-themes.sh

This file was deleted.

27 changes: 0 additions & 27 deletions .chezmoiscripts/run_onchange_install-btop-themes.sh

This file was deleted.

21 changes: 0 additions & 21 deletions .chezmoiscripts/run_onchange_install-fresh-themes.sh.tmpl

This file was deleted.

51 changes: 0 additions & 51 deletions .chezmoiscripts/run_onchange_install-k9s-theme.sh.tmpl

This file was deleted.

14 changes: 0 additions & 14 deletions .chezmoiscripts/run_onchange_mise-install.sh

This file was deleted.

17 changes: 17 additions & 0 deletions .chezmoiscripts/run_onchange_mise-install.sh.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash
# Installs all runtimes and tools declared in the mise global config.
# Re-runs whenever that config changes (hash below) or this script changes.
# mise config hash: {{ include "dot_config/mise/config.toml.tmpl" | sha256sum }}

set -euo pipefail

export PATH="/opt/homebrew/bin:$PATH"

if ! command -v mise &>/dev/null; then
echo "mise not found — skipping. Install via: brew install mise"
exit 0
fi

echo "Installing mise runtimes..."
mise install --yes
echo "✅ mise install complete."
42 changes: 3 additions & 39 deletions .chezmoiscripts/run_onchange_navi-cheats.sh.tmpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
# Regenerates ~/.local/share/navi/cheats/personal.cheat from aliases and functions,
# and ensures community cheatsheet repos are cloned.
# Regenerates ~/.local/share/navi/cheats/personal.cheat from aliases and functions.
# Community cheat repos are fetched declaratively via .chezmoiexternal.toml.tmpl.
# dot_zsh/aliases.zsh hash: {{ include "dot_zsh/aliases.zsh.tmpl" | sha256sum }}
# dot_zsh/functions.zsh.tmpl hash: {{ include "dot_zsh/functions.zsh.tmpl" | sha256sum }}

Expand All @@ -21,7 +21,7 @@ cmd python3 || {
CHEAT_DIR="$HOME/.local/share/navi/cheats"
mkdir -p "$CHEAT_DIR"

# --- 1. Generate personal.cheat from aliases.zsh and functions.zsh ---
# Generate personal.cheat from aliases.zsh and functions.zsh
python3 - "$HOME/.zsh/aliases.zsh" "$HOME/.zsh/functions.zsh" <<'PYEOF' >"$CHEAT_DIR/personal.cheat"
import re, sys

Expand Down Expand Up @@ -78,39 +78,3 @@ print("".join(out))
PYEOF

echo "✅ Generated $CHEAT_DIR/personal.cheat"

# --- 2. Community repos — clone if missing, pull if older than 7 days ---
# Uses git clone directly to avoid navi repo add's interactive file picker.
REPO_CACHE="$CHEAT_DIR/.last_updated"
_needs_update() {
[[ ! -f "$REPO_CACHE" ]] && return 0
local age=$(($(date +%s) - $(date -r "$REPO_CACHE" +%s)))
((age > 604800)) # 7 days in seconds
}

add_repo() {
local repo="$1"
local dest="$CHEAT_DIR/${repo//\//__}"
if [[ ! -d "$dest/.git" ]]; then
# Missing, or a stale non-git directory from an interrupted clone.
[[ "$dest" == "$CHEAT_DIR/"?* ]] && rm -rf "$dest"
echo "Cloning navi repo: $repo ..."
git clone --depth=1 --quiet "https://github.com/${repo}.git" "$dest" ||
echo "⚠️ Could not clone $repo (check network)"
elif _needs_update; then
echo "Updating navi repo: $repo ..."
git -C "$dest" fetch --depth=1 --quiet origin HEAD &&
git -C "$dest" reset --quiet --hard FETCH_HEAD ||
echo "⚠️ Could not update $repo"
fi
}

add_repo "denisidoro/cheats"
add_repo "denisidoro/navi-tldr-pages"
add_repo "tg-z/navi-cheats"
{{ if .kubernetes -}}
add_repo "tsologub/navi-cheats"
{{ end -}}

_needs_update && touch "$REPO_CACHE"
echo "✅ Navi setup complete."
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ Package categories you can toggle:
On first apply, chezmoi automatically:

1. Runs `brew bundle --global` to install all selected Homebrew packages
2. Runs `mise install` to set up language runtimes
2. Runs `mise install` to set up language runtimes and global npm tools
3. Generates static init files and completions (`~/.zsh/*_init.zsh`, `~/.zsh/completions/`)
4. Seeds a Colima config (`~/.colima/default/colima.yaml`) optimised for Apple Silicon
5. Generates navi cheatsheets and clones community repos
5. Generates `personal.cheat` for navi; fetches external assets (community cheats, editor/tool themes) via `.chezmoiexternal`

## Forking

Expand Down Expand Up @@ -140,7 +140,7 @@ Tool inits (atuin, zoxide, direnv, navi, etc.) are pre-generated once rather tha
| Command | Description |
| ------- | ----------- |
| `mnt` | Full maintenance: sync dotfiles, brew upgrade, sheldon update, regenerate inits & completions, recompile, backup, reload |
| `brew-up` | Homebrew update + upgrade + cleanup + tldr update |
| `brew-up` | Homebrew update + upgrade + cleanup + tldr update, then refresh the static tool-init caches |
| `pkg-cats` | List all package categories with their descriptions and package lists |
| `brewsync` | Interactively promote untracked brew packages into the chezmoi-managed Brewfile |
| `comp-add <tool>` | Auto-detect and add zsh completions for a new tool; persists to chezmoi source |
Expand Down Expand Up @@ -240,7 +240,7 @@ To remove a package permanently: `pkg-rm <package>` — removes it from the Brew

[navi](https://github.com/denisidoro/navi) is a command-line cheatsheet tool. Press **Ctrl+G** mid-command to search cheatsheets and insert a command into the prompt. Or run `navi` to browse interactively.

On first `chezmoi apply`, `run_onchange_navi-cheats.sh.tmpl` auto-generates `~/.local/share/navi/cheats/personal.cheat` from your aliases and functions, and clones community repos. The personal cheat file is regenerated automatically whenever `aliases.zsh` or `functions.zsh` changes.
On first `chezmoi apply`, `run_onchange_navi-cheats.sh.tmpl` generates `~/.local/share/navi/cheats/personal.cheat` from your aliases and functions (regenerated whenever `aliases.zsh` or `functions.zsh` changes). The community cheat repos are fetched and refreshed weekly by chezmoi via `.chezmoiexternal.toml.tmpl`.

| Source | What it covers |
| ------ | -------------- |
Expand Down Expand Up @@ -268,6 +268,8 @@ On first `chezmoi apply`, `run_onchange_navi-cheats.sh.tmpl` auto-generates `~/.
| btop | `~/.config/btop/themes/` (all four flavours: latte, frappé, macchiato, mocha) |
| k9s | `~/.config/k9s/skins/` (all flavours; follows macOS appearance via `sync-theme`) *(kubernetes only)* |

Theme files (bat/btop/fresh `.tmTheme`/`.theme`/`.json`, k9s skins) are fetched and refreshed by chezmoi via `.chezmoiexternal.toml.tmpl`.

`sync-theme` (`~/.local/bin/sync-theme`) switches delta, starship, atuin, eza, lazygit, and k9s between Latte and Macchiato. It is called by Hammerspoon (`~/.hammerspoon/init.lua`) which watches `AppleInterfaceThemeChangedNotification` — so all tools switch instantly when you toggle macOS appearance. ghostty is not part of sync-theme; it follows the appearance natively.

Override manually with `theme dark` or `theme light`.
Expand Down
Loading
Loading