9836aebe672159622193f14a89eedc38ccd29a5d

Author
Marc Cornellà <hello@mcornella.com>
Committer
Marc Cornellà <hello@mcornella.com>
Date

Message

fix(agnoster): quote % in prompt functions

Diff

 1diff --git a/themes/agnoster.zsh-theme b/themes/agnoster.zsh-theme
 2index fe7ddbac639e24a645e32791af8cc1ba310f266f..5f4efe813b4aadc49efa42d30fbbe8d8c2c43cf7 100644
 3--- a/themes/agnoster.zsh-theme
 4+++ b/themes/agnoster.zsh-theme
 5@@ -135,7 +135,7 @@ prompt_git() {
 6     zstyle ':vcs_info:*' formats ' %u%c'
 7     zstyle ':vcs_info:*' actionformats ' %u%c'
 8     vcs_info
 9-    echo -n "${ref/refs\/heads\//$PL_BRANCH_CHAR }${vcs_info_msg_0_%% }${mode}"
10+    echo -n "${${ref:gs/%/%%}/refs\/heads\//$PL_BRANCH_CHAR }${vcs_info_msg_0_%% }${mode}"
11   fi
12 }
13 
14@@ -153,7 +153,7 @@ prompt_bzr() {
15   if bzr_status=$(bzr status 2>&1); then
16     status_mod=$(echo -n "$bzr_status" | head -n1 | grep "modified" | wc -m)
17     status_all=$(echo -n "$bzr_status" | head -n1 | wc -m)
18-    revision=$(bzr log -r-1 --log-format line | cut -d: -f1)
19+    revision=${$(bzr log -r-1 --log-format line | cut -d: -f1):gs/%/%%}
20     if [[ $status_mod -gt 0 ]] ; then
21       prompt_segment yellow black "bzr@$revision ✚"
22     else
23@@ -183,7 +183,7 @@ prompt_hg() {
24         # if working copy is clean
25         prompt_segment green $CURRENT_FG
26       fi
27-      echo -n $(hg prompt "☿ {rev}@{branch}") $st
28+      echo -n ${$(hg prompt "☿ {rev}@{branch}"):gs/%/%%} $st
29     else
30       st=""
31       rev=$(hg id -n 2>/dev/null | sed 's/[^-0-9]//g')
32@@ -197,7 +197,7 @@ prompt_hg() {
33       else
34         prompt_segment green $CURRENT_FG
35       fi
36-      echo -n "☿ $rev@$branch" $st
37+      echo -n "☿ ${rev:gs/%/%%}@${branch:gs/%/%%}" $st
38     fi
39   fi
40 }
41@@ -209,9 +209,8 @@ prompt_dir() {
42 
43 # Virtualenv: current working virtualenv
44 prompt_virtualenv() {
45-  local virtualenv_path="$VIRTUAL_ENV"
46-  if [[ -n $virtualenv_path && -n $VIRTUAL_ENV_DISABLE_PROMPT ]]; then
47-    prompt_segment blue black "(`basename $virtualenv_path`)"
48+  if [[ -n "$VIRTUAL_ENV" && -n "$VIRTUAL_ENV_DISABLE_PROMPT" ]]; then
49+    prompt_segment blue black "(${VIRTUAL_ENV:t:gs/%/%%})"
50   fi
51 }
52 
53@@ -237,8 +236,8 @@ prompt_status() {
54 prompt_aws() {
55   [[ -z "$AWS_PROFILE" || "$SHOW_AWS_PROMPT" = false ]] && return
56   case "$AWS_PROFILE" in
57-    *-prod|*production*) prompt_segment red yellow  "AWS: $AWS_PROFILE" ;;
58-    *) prompt_segment green black "AWS: $AWS_PROFILE" ;;
59+    *-prod|*production*) prompt_segment red yellow  "AWS: ${AWS_PROFILE:gs/%/%%}" ;;
60+    *) prompt_segment green black "AWS: ${AWS_PROFILE:gs/%/%%}" ;;
61   esac
62 }
63