3 # Prefix at the very beginning of the prompt, before the branch name
4 ZSH_THEME_FOSSIL_PROMPT_PREFIX="%{$fg_bold[blue]%}fossil:(%{$fg_bold[red]%}"
6 # At the very end of the prompt
7 ZSH_THEME_FOSSIL_PROMPT_SUFFIX="%{$fg_bold[blue]%})"
9 # Text to display if the branch is dirty
10 ZSH_THEME_FOSSIL_PROMPT_DIRTY=" %{$fg_bold[red]%}✖"
12 # Text to display if the branch is clean
13 ZSH_THEME_FOSSIL_PROMPT_CLEAN=" %{$fg_bold[green]%}✔"
15 function fossil_prompt_info() {
16 local branch=$(fossil branch current 2>&1)
18 # if we're not in a fossil repo, don't show anything
19 ! command grep -q "use --repo" <<< "$branch" || return
21 local changes=$(fossil changes)
22 local dirty="$ZSH_THEME_FOSSIL_PROMPT_CLEAN"
24 if [[ -n "$changes" ]]; then
25 dirty="$ZSH_THEME_FOSSIL_PROMPT_DIRTY"
28 printf '%s %s %s %s %s' \
29 "$ZSH_THEME_FOSSIL_PROMPT_PREFIX" \
31 "$ZSH_THEME_FOSSIL_PROMPT_SUFFIX" \
36 function _fossil_prompt () {
37 local current=`echo $PROMPT $RPROMPT | grep fossil`
39 if [ "$_FOSSIL_PROMPT" = "" -o "$current" = "" ]; then
40 local _prompt=${PROMPT}
41 local _rprompt=${RPROMPT}
43 local is_prompt=`echo $PROMPT | grep git`
45 if [ "$is_prompt" = "" ]; then
46 RPROMPT="$_rprompt"'$(fossil_prompt_info)'
48 PROMPT="$_prompt"'$(fossil_prompt_info) '
55 autoload -U add-zsh-hook
56 add-zsh-hook precmd _fossil_prompt