Files
oh-my-zsh/plugins/fossil/fossil.plugin.zsh
T
10ffeda6b5 fix(fossil)!: reduce prompt spacing (#11141)
BREAKING CHANGE: the fossil plugin now ships a prompt function that
removes spacing between segments. Spaces can always be added by
changing the setting variables. Check out the README for details.

* Reduced unnecessary space in Fossil plugin prompt

The prior version was way too opinionated, adding space between each element of the prompt string, unlike common Git prompt strings.  If the user wants more space, they can override our public variables to suit.  The inverse argument doesn't hold: it's easy to add space to existing variables, but not as easy to remove it after the fact.

As part of this, changed the branch name from red to blue (matching the preceding part of the prompt) so the red "X" added to indicate a dirty branch doesn't get lost in the branch name.

* fix(fossil): keep the branch name red
* Document fossil prompt settings

---------

Co-authored-by: Robby Russell <robby@planetargon.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Marc Cornellà <marc@mcornella.com>
2026-12-02 19:27:35 +01:00

57 lines
1.4 KiB
Bash

_FOSSIL_PROMPT=""
# Prefix at the very beginning of the prompt, before the branch name
ZSH_THEME_FOSSIL_PROMPT_PREFIX="%{$fg_bold[blue]%}fossil:(%{$fg_bold[red]%}"
# At the very end of the prompt
ZSH_THEME_FOSSIL_PROMPT_SUFFIX="%{$fg_bold[blue]%})"
# Text to display if the branch is dirty
ZSH_THEME_FOSSIL_PROMPT_DIRTY="%{$fg_bold[red]%}✖"
# Text to display if the branch is clean
ZSH_THEME_FOSSIL_PROMPT_CLEAN="%{$fg_bold[green]%}✔"
function fossil_prompt_info() {
local branch=$(fossil branch current 2>&1)
# if we're not in a fossil repo, don't show anything
! command grep -q "use --repo" <<< "$branch" || return
local changes=$(fossil changes)
local dirty="$ZSH_THEME_FOSSIL_PROMPT_CLEAN"
if [[ -n "$changes" ]]; then
dirty="$ZSH_THEME_FOSSIL_PROMPT_DIRTY"
fi
printf ' %s%s%s%s%s' \
"$ZSH_THEME_FOSSIL_PROMPT_PREFIX" \
"${branch:gs/%/%%}" \
"$dirty" \
"$ZSH_THEME_FOSSIL_PROMPT_SUFFIX" \
"%{$reset_color%}"
}
function _fossil_prompt () {
local current=`echo $PROMPT $RPROMPT | grep fossil`
if [ "$_FOSSIL_PROMPT" = "" -o "$current" = "" ]; then
local _prompt=${PROMPT}
local _rprompt=${RPROMPT}
local is_prompt=`echo $PROMPT | grep git`
if [ "$is_prompt" = "" ]; then
RPROMPT="$_rprompt"'$(fossil_prompt_info)'
else
PROMPT="$_prompt"'$(fossil_prompt_info) '
fi
_FOSSIL_PROMPT="1"
fi
}
autoload -U add-zsh-hook
add-zsh-hook precmd _fossil_prompt