mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-12 08:50:08 +00:00
fix(fossil): refactor fossil_prompt_info
and quote % in branch
This commit is contained in:
parent
1c53ef0583
commit
a280726d93
1 changed files with 16 additions and 14 deletions
|
@ -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
|
|
||||||
local _EDITED=`fossil changes`
|
|
||||||
local _EDITED_SYM="$ZSH_THEME_FOSSIL_PROMPT_CLEAN"
|
|
||||||
local _BRANCH=`echo $_OUTPUT | grep "* " | sed 's/* //g'`
|
|
||||||
|
|
||||||
if [ "$_EDITED" != "" ]; then
|
# if we're not in a fossil repo, don't show anything
|
||||||
_EDITED_SYM="$ZSH_THEME_FOSSIL_PROMPT_DIRTY"
|
! command grep -q "use --repo" <<< "$info" || return
|
||||||
fi
|
|
||||||
|
|
||||||
echo "$ZSH_THEME_FOSSIL_PROMPT_PREFIX" \
|
local branch=$(echo $info | grep "* " | sed 's/* //g')
|
||||||
"$_BRANCH" \
|
local changes=$(fossil changes)
|
||||||
"$ZSH_THEME_FOSSIL_PROMPT_SUFFIX" \
|
local dirty="$ZSH_THEME_FOSSIL_PROMPT_CLEAN"
|
||||||
"$_EDITED_SYM"\
|
|
||||||
"%{$reset_color%}"
|
if [[ -n "$changes" ]]; then
|
||||||
|
dirty="$ZSH_THEME_FOSSIL_PROMPT_DIRTY"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
printf '%s %s %s %s %s' \
|
||||||
|
"$ZSH_THEME_FOSSIL_PROMPT_PREFIX" \
|
||||||
|
"${branch:gs/%/%%}" \
|
||||||
|
"$ZSH_THEME_FOSSIL_PROMPT_SUFFIX" \
|
||||||
|
"$dirty" \
|
||||||
|
"%{$reset_color%}"
|
||||||
}
|
}
|
||||||
|
|
||||||
function _fossil_prompt () {
|
function _fossil_prompt () {
|
||||||
|
|
Loading…
Reference in a new issue