Skip to main content

Module git_alias

Module git_alias 

Source
Expand description

dodot git-show-alias and dodot git-install-alias — the Tier 2 shell-side glue for the template-magic flow.

Tier 1 (R4) gets you commit-time correctness via the pre-commit hook. Tier 2 makes interactive git status and git diff show the truth between commits too, by wrapping git in a shell alias that runs dodot refresh --quiet first. The clean filter (R6) does the heavy lifting once the source mtime is fresh; this alias is what nudges the mtime on every interactive git invocation.

Two forms:

  • dodot git-show-alias — print the alias for the user’s shell (detected from $SHELL) so they can copy-paste into their rc file. No filesystem mutation.
  • dodot git-install-alias — write the alias to the user’s rc file (~/.bashrc or ~/.zshrc) with an idempotent guard block, mirroring the pre-commit hook installer’s pattern.

Only affects interactive shells. Scripts, editors, and CI that shell out to git directly are unaffected — exactly what we want: non-interactive callers get predictable behaviour, interactive use gets the magic.

Structs§

InstallAliasResult
ShowAliasResult
Result of dodot git-show-alias — the alias body the user can paste, plus the rc file we’d write it to (so the rendered output can show “add this to ~/.zshrc”).

Enums§

InstallAliasOutcome
Outcome of dodot git-install-alias. Mirrors InstallHookOutcome.
Shell
Which shell we’re targeting. Detected from $SHELL for the bare show/install flow; the user can override with --shell at the CLI layer.

Functions§

install_alias
is_installed
Cheap “is this rc file already wrapping git via our alias?” check, used by the future post-up prompt. Reads the rc file and looks for the guard. Doesn’t error out if the file is missing — that’s a normal “not installed” state.
managed_block
The full guarded block that install_alias writes (or that show_alias prints for copy-paste). Mirrors the pre-commit hook’s managed_block shape.
resolve_shell
Diagnostic helper for the CLI: detect or validate a shell from the --shell CLI value, surfacing a clear error for unknown shells. Returns the resolved Shell or a DodotError::Other.
show_alias