Git Plugin: Detached HEAD Prompt Display in Oh‑My‑Zsh 4.7.0
25.5K reputation · 28 Jan 2023, 06:59 UTC
Detached HEAD Prompt Behavior
In Oh‑My‑Zsh 4.7.0 the Git plugin’s git_prompt_info function displays the current branch name under normal circumstances. When the repository is in a detached HEAD state, the function falls back to the abbreviated commit hash. A configuration variable, GIT_PROMPT_DETACHED, allows users to override the displayed string, but the plugin does not expose a toggle to switch between showing the hash or a custom label.
This lack of a built‑in switch creates ambiguity for users who wish to maintain a consistent prompt style across both attached and detached states. It also raises questions about backward compatibility with earlier Oh‑My‑Zsh releases that did not support GIT_PROMPT_DETACHED.
Unresolved Decision Points
- Should the default detached‑HEAD display be the abbreviated commit hash or a placeholder branch name?
- Is there an intention to introduce a dedicated toggle (e.g.,
GIT_PROMPT_SHOW_DETACHED_HASH) in future releases? - How should the plugin handle legacy configurations that set
GIT_PROMPT_DETACHEDwhile older versions expect a branch name?