Utilities - uhop/dotfiles GitHub Wiki

Utilities

Custom CLI utilities in ~/.local/bin/. Bash utilities use options.bash for option parsing and rich terminal output. JS utilities run on Node.js (22.7+, ESM auto-detect).

Designed for Tab

Every utility here ships a bash completion โ€” subcommands, options, and where it makes sense, positional arguments โ€” so the intended way to drive them is Tab-first, not memorize-the-flags.

  • Less typing, less remembering. Type the command, hit Tab, pick what you need.
  • Discoverable. A flag you've never used appears in the completion list; you don't need to re-read --help.
  • Pairs with fzf. Ctrl+R replays any command you've run before; Tab fills in the options you haven't. Together they collapse the gap between "I know what I want" and "I've typed it."
  • options.bash does the plumbing. Completions are generated from each tool's option spec and installed under ~/.local/share/bash-completion/completions/. If a flag changes, regenerate with clean-completions + next shell start.

Reach for Tab liberally โ€” these tools assume you will.

pick

Interactive command reference. Presents available commands by topic via fzf, shows a doc line with options and arguments, lets you edit the command, then echoes and runs it.

Usage:

pick              # list topics, pick one, then pick a command
pick git          # jump to git commands
pick docker       # jump to docker / dcm commands
git pick          # same as pick git (via git-pick)
h                 # alias for pick
h git             # alias for pick git

Topics shipped today: git, rsync, system, docker, ssh, playbash, files. The active list is whatever ~/.local/share/pick/*.json contains.

Flow: fzf shows commands with descriptions. A preview pane shows extended docs (option flags, argument specs). On selection, commands without arguments execute immediately; commands that take arguments present an editable prompt pre-filled with the command โ€” append flags and hit Enter.

Topics are JSON files in ~/.local/share/pick/, one per topic. Adding a topic is adding a file. Each entry has cmd, desc, optional doc (shown in preview), and optional args (false = execute immediately).

Complementary to pet (personal snippets with gist sync). pick is the curated dotfiles reference; pet is for ad-hoc snippets you save over time.

System maintenance

upd

Update software with all available package managers.

Usage:

upd [options]

Options:

Option Description
-c, --clean Run cln after updating
-y, --yes Assume "yes" to all prompts
-r, --restart-services After a docker-ce upgrade, restart containerd + docker instead of asking for a full reboot
-v, --version Show version
-h, --help Show help

What it updates (platform-dependent):

  • apt update + apt upgrade (Debian)
  • dnf upgrade (Red Hat-like)
  • snap refresh (Debian)
  • flatpak update
  • softwareupdate (macOS)
  • mas upgrade (macOS)
  • brew update + brew upgrade
  • tmux plugins (via TPM)
  • bun upgrade

On Debian, after updating, scans the apt history for docker-related upgrades, AppArmor upgrades, and /run/reboot-required, then surfaces structured warnings via maintenance.sh (printed locally; also written to $PLAYBASH_REPORT when run under playbash). With -r, a detected docker-ce/containerd/docker-buildx-plugin/docker-compose-plugin upgrade triggers sudo systemctl restart containerd && sudo systemctl restart docker (both whitelisted in /etc/sudoers.d/chezmoi, or in doas.conf if doas is installed โ€” see Application Notes ยง passwordless privilege escalation); on failure, falls back to a reboot recommendation.

Use upd -c to run a full update followed by cleanup (equivalent to running upd then cln).

cln

Clean unused versions and caches of software.

Usage:

cln [options]

Options:

Option Description
-y, --yes Assume "yes" to all prompts
-v, --version Show version
-h, --help Show help

What it cleans (platform-dependent):

  • apt autoremove + apt autoclean (Debian)
  • dnf autoremove + dnf clean all (Red Hat-like)
  • flatpak uninstall --unused
  • brew autoremove + brew cleanup --prune=all --scrub
  • docker system prune -a
  • Node.js: updates major versions via update-node-versions, trims old minor versions via trim-node-versions

update-dependencies

Clone or update the options.bash library.

If ~/.local/share/libs/scripts exists, pulls the latest changes. Otherwise, clones it as a sparse worktree (only *.sh and README.md).

Usage:

update-dependencies

update-node-versions

Install the latest minor for every Node major that nvm has installed โ€” nvm install <major> per major, oldest to newest. Runs nvm in-process (bash sources nvm.sh directly). -n, --dry-run previews the nvm calls.

trim-node-versions

Keep the newest minor of every installed Node major and nvm uninstall the rest, switching away first when the current version is being removed. Runs nvm in-process, so the nvm use actually persists for the following uninstall โ€” the failure mode the previous Node implementation hit on macOS (a Node script cannot switch away from, or prune, the Node version executing it). -n, --dry-run previews the nvm calls.

Both tools were converted from JS to bash on 2026-07-11; the ~/.local/share/utils/ JS helpers (comp.js, semver.js, nvm.js) retired with them.

ollama-sync

Update all installed ollama models by pulling the latest version of each.

Usage:

ollama-sync [options]

Options:

Option Description
-v, --version Show version
-h, --help Show help

dcm

Manage Docker Compose setups with automatic AppArmor recovery on Linux. See dcm for full documentation.

flatpak-install

Install flatpak packages, dispatching between --system and --user scopes. Dedups across scopes, prefers system install when the managed polkit rule is in play (SSH-safe) or when passwordless sudo is available, falls back to user install for non-sudoers. See flatpak-install for full documentation.

clean-completions

Remove bash completion files generated by options.bash. Mostly useful when iterating on a script's option set: stale completions can suggest flags that no longer exist.

Usage:

clean-completions

Multi-host orchestration of upd, cln, dcm, dcms, and friends is handled by playbash โ€” see Playbash Server Management.

setup-periodic

Set up periodic scheduled tasks using systemd timers (Linux) or launchd system daemons (macOS). See setup-periodic for full documentation, schedule syntax, and notification wrappers.

File operations

imop

Optimize and convert images for the web. Automatically selects the best available tool for each format with fallback chains. See imop for full documentation, supported formats, and tool preference chains.

cxop

Pre-compress files into .gz/.br/.zst siblings for HTTP Accept-Encoding content negotiation. Negative-list file selection with a size-check safety net; decompression pairs with arx. See cxop for full documentation, codec tools, and deploy-pipeline integration.

cdn-inv

CloudFront invalidation CLI. Thin bash wrapper over aws cloudfront โ€” cdn-inv list, cdn-inv find <domain> (alias โ†’ distribution ID), cdn-inv invalidate <domain> [paths...] with built-in completion-wait. Profile via AWS_PROFILE=X cdn-inv .... See cdn-inv for full usage and deploy-chain integration.

ghmeta

Sync package.json metadata with the GitHub repo: description โ†” About, keywords โ†” topics. ghmeta pushes (default; whole-set topic replace with normalization), ghmeta pull copies GitHub โ†’ package.json; -n previews either direction. See ghmeta for full usage and topic normalization rules.

arx

View and extract archives of various types. Handles compression and archive formats automatically. See arx for full documentation and supported formats.

jot

Encrypted notes editor using AWS S3 as storage. Files are decoded by extension. See jot for full documentation, environment variables, and supported codecs.

jot-bundle / jot-deploy

Manifest-driven helpers for collecting a defined set of system files and reinstalling them on another machine via jot. jot-bundle gathers and uploads; jot-deploy is dry-run by default with --apply to install. See Jot ยง Bundle helpers.

Directory operations

goup

Run a command in the current directory and each parent directory up to /.

Usage:

goup "make test"
goup "ls package.json 2>/dev/null && npm test"

Options:

Option Description
-v, --version Show version
-h, --help Show help

The working directory is restored after execution completes.

mount-raid

Mount a remote NFS filesystem as /media/raid (Linux) or /Volumes/raid (macOS).

Usage:

mount-raid server-name

Options:

Option Description
-v, --version Show version
-h, --help Show help

Requires sudo. Uses hard,timeo=600,rsize=1048576,wsize=1048576 mount options.

Bootstrap helpers

bootstrap-remote

Set up SSH access to a vanilla remote host: copy your public key and harden sshd_config.

Usage:

bootstrap-remote newhost              # dry-run (shows what would happen)
bootstrap-remote newhost --apply      # execute for real
bootstrap-remote newhost --apply --skip-harden  # key only, no hardening

Options:

Option Description
--apply Execute commands (default: dry-run)
--skip-copy-key Skip SSH key distribution
--skip-harden Skip sshd_config hardening
-k, --key Public key to copy (default: auto-detect)

Hardening sets PasswordAuthentication no and PermitRootLogin no, then verifies access. Rolls back automatically on failure. See Setting Up a New Machine.

bootstrap-dotfiles

Thin wrapper over install.sh. Runs the curl-pipe entry point remotely over SSH or locally with an optional jot-deploy tail.

Usage:

# Remote: SSH + curl-pipe. Runs install.sh --yes on newhost.
bootstrap-dotfiles newhost

# Local self-bootstrap + pull secrets from S3 via jot-deploy.
bootstrap-dotfiles --from-jot my-bundle-prefix

Options:

Option Description
--github-user <name> GitHub user owning the dotfiles repo (default: $GITHUB_USERNAME or uhop)
--branch <br> Branch of the dotfiles repo to fetch install.sh from (default: main)
--from-jot <prefix> Self-bootstrap locally; run jot-deploy <prefix> after chezmoi apply

The actual OS-specific logic โ€” prereqs, Homebrew, chezmoi init โ€” lives in install.sh at the repo root. bootstrap-dotfiles owns only the surrounding flow (SSH reachability check, jot pre-flight, jot-deploy tail). See also the curl-pipe option for bootstrapping without an operator machine.

Git helpers

gpurr

Pull the current repo with submodule recursion, then pull the main branch in each submodule.

gpurr

gpwiki

Pull the current repo, then pull the main branch in wiki/ if it exists.

gpwiki

git-br

Pretty-formatted git branch showing branch name, subject, relative date, and author.

git br           # local branches
git br --all     # all branches

git-brr

Remote branches sorted by committer date (most recent first).

git brr

git-bs

Branch list sorted by author date in columnar format (date, author, branch, subject).

git bs           # local branches
git bs --all     # all branches

git-mbs

Filter git-bs --all to show only branches by the current git user.

git mbs

git-pull-main

Auto-detect the default branch from origin, checkout, and pull it.

git pull-main

git-super-clean

Hard reset and deep clean: git reset --hard followed by git clean --force -d -x.

git super-clean

Warning: This removes all untracked files and directories, including ignored ones.

Node.js helpers

These utilities run on Bun and manage Node.js versions installed via nvm.

update-node-versions.js

Update each installed major Node.js version to its latest release. For example, if Node 18.15.0 and 20.10.0 are installed, it runs nvm install 18 and nvm install 20 to get the latest patch versions.

update-node-versions.js

trim-node-versions.js

Remove old minor/patch versions of Node.js, keeping only the latest version per major. For example, if both 20.10.0 and 20.11.0 are installed, it removes 20.10.0.

trim-node-versions.js

Supporting modules

Modules live in ~/.local/share/utils/:

  • comp.js โ€” Sorting comparator and less-function adapters (adaptLess, compareNumbers, compareStrings, adaptReverse)
  • semver.js โ€” Semver parsing and comparison (getVersion, compareVersions, toVersionString)
  • nvm.js โ€” nvm integration (runNvm, getNodeVersions)
โš ๏ธ **GitHub.com Fallback** โš ๏ธ