fix(fossil): refactor `fossil_prompt_info` and quote % in branch

parent 1c53ef05
...@@ -13,23 +13,25 @@ ZSH_THEME_FOSSIL_PROMPT_DIRTY=" %{$fg_bold[red]%}✖" ...@@ -13,23 +13,25 @@ ZSH_THEME_FOSSIL_PROMPT_DIRTY=" %{$fg_bold[red]%}✖"
ZSH_THEME_FOSSIL_PROMPT_CLEAN=" %{$fg_bold[green]%}✔" ZSH_THEME_FOSSIL_PROMPT_CLEAN=" %{$fg_bold[green]%}✔"
function fossil_prompt_info() { function fossil_prompt_info() {
local _OUTPUT=`fossil branch 2>&1` local info=$(fossil branch 2>&1)
local _STATUS=`echo $_OUTPUT | grep "use --repo"`
if [ "$_STATUS" = "" ]; then # if we're not in a fossil repo, don't show anything
local _EDITED=`fossil changes` ! command grep -q "use --repo" <<< "$info" || return
local _EDITED_SYM="$ZSH_THEME_FOSSIL_PROMPT_CLEAN"
local _BRANCH=`echo $_OUTPUT | grep "* " | sed 's/* //g'` local branch=$(echo $info | grep "* " | sed 's/* //g')
local changes=$(fossil changes)
if [ "$_EDITED" != "" ]; then local dirty="$ZSH_THEME_FOSSIL_PROMPT_CLEAN"
_EDITED_SYM="$ZSH_THEME_FOSSIL_PROMPT_DIRTY"
if [[ -n "$changes" ]]; then
dirty="$ZSH_THEME_FOSSIL_PROMPT_DIRTY"
fi fi
echo "$ZSH_THEME_FOSSIL_PROMPT_PREFIX" \ printf '%s %s %s %s %s' \
"$_BRANCH" \ "$ZSH_THEME_FOSSIL_PROMPT_PREFIX" \
"${branch:gs/%/%%}" \
"$ZSH_THEME_FOSSIL_PROMPT_SUFFIX" \ "$ZSH_THEME_FOSSIL_PROMPT_SUFFIX" \
"$_EDITED_SYM"\ "$dirty" \
"%{$reset_color%}" "%{$reset_color%}"
fi
} }
function _fossil_prompt () { function _fossil_prompt () {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment