summaryrefslogtreecommitdiff
path: root/plugins/fossil
diff options
context:
space:
mode:
authorTuowen Zhao <ztuowen@gmail.com>2022-02-19 17:12:23 -0600
committerTuowen Zhao <ztuowen@gmail.com>2022-02-19 17:12:23 -0600
commitcae9a2b797649379e865e6bd73bc67e294e4ac77 (patch)
tree481419eff4bc761c3ca516704427394193473419 /plugins/fossil
parent49edbf438ed690c76e6b2af80368c59404cf0167 (diff)
parent3427da4057dbe302933a7b5b19b4e23bfb9d0969 (diff)
downloadzsh-cae9a2b797649379e865e6bd73bc67e294e4ac77.tar.gz
zsh-cae9a2b797649379e865e6bd73bc67e294e4ac77.tar.bz2
zsh-cae9a2b797649379e865e6bd73bc67e294e4ac77.zip
Merge remote-tracking branch 'origin/master'
Diffstat (limited to 'plugins/fossil')
-rw-r--r--plugins/fossil/fossil.plugin.zsh32
1 files changed, 17 insertions, 15 deletions
diff --git a/plugins/fossil/fossil.plugin.zsh b/plugins/fossil/fossil.plugin.zsh
index dfad73d36..a2123f415 100644
--- a/plugins/fossil/fossil.plugin.zsh
+++ b/plugins/fossil/fossil.plugin.zsh
@@ -13,23 +13,25 @@ ZSH_THEME_FOSSIL_PROMPT_DIRTY=" %{$fg_bold[red]%}✖"
ZSH_THEME_FOSSIL_PROMPT_CLEAN=" %{$fg_bold[green]%}✔"
function fossil_prompt_info() {
- 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
+ local info=$(fossil branch 2>&1)
+
+ # if we're not in a fossil repo, don't show anything
+ ! command grep -q "use --repo" <<< "$info" || return
- echo "$ZSH_THEME_FOSSIL_PROMPT_PREFIX" \
- "$_BRANCH" \
- "$ZSH_THEME_FOSSIL_PROMPT_SUFFIX" \
- "$_EDITED_SYM"\
- "%{$reset_color%}"
+ local branch=$(echo $info | grep "* " | sed 's/* //g')
+ 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/%/%%}" \
+ "$ZSH_THEME_FOSSIL_PROMPT_SUFFIX" \
+ "$dirty" \
+ "%{$reset_color%}"
}
function _fossil_prompt () {