2016-05-10 18:23:23 +02:00
|
|
|
_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]%}✔"
|
|
|
|
|
2021-12-28 19:04:45 +01:00
|
|
|
function fossil_prompt_info() {
|
2016-05-10 18:23:23 +02:00
|
|
|
local _OUTPUT=`fossil branch 2>&1`
|
|
|
|
local _STATUS=`echo $_OUTPUT | grep "use --repo"`
|
|
|
|
if [ "$_STATUS" = "" ]; then
|
|
|
|
local _EDITED=`fossil changes`
|
|
|
|
local _EDITED_SYM="$ZSH_THEME_FOSSIL_PROMPT_CLEAN"
|
|
|
|
local _BRANCH=`echo $_OUTPUT | grep "* " | sed 's/* //g'`
|
|
|
|
|
|
|
|
if [ "$_EDITED" != "" ]; then
|
|
|
|
_EDITED_SYM="$ZSH_THEME_FOSSIL_PROMPT_DIRTY"
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "$ZSH_THEME_FOSSIL_PROMPT_PREFIX" \
|
|
|
|
"$_BRANCH" \
|
|
|
|
"$ZSH_THEME_FOSSIL_PROMPT_SUFFIX" \
|
|
|
|
"$_EDITED_SYM"\
|
|
|
|
"%{$reset_color%}"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
2021-03-15 23:27:57 +01:00
|
|
|
RPROMPT="$_rprompt"'$(fossil_prompt_info)'
|
2016-05-10 18:23:23 +02:00
|
|
|
else
|
2021-03-15 23:27:57 +01:00
|
|
|
PROMPT="$_prompt"'$(fossil_prompt_info) '
|
2016-05-10 18:23:23 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
_FOSSIL_PROMPT="1"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
autoload -U add-zsh-hook
|
|
|
|
add-zsh-hook precmd _fossil_prompt
|