summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordaniel g. siegel2015-11-04 13:02:30 +0100
committerdaniel g. siegel2015-11-04 13:02:30 +0100
commitabb917e2b54c0039843ad8f7af3bb774cc9a1249 (patch)
treea4df8fbef39b078c3b45e72fd9b6b773679dd4b1
parentfc8c9a9fca82acb19ffe27a0fc82cd4f91cb073d (diff)
downloadzsh-prompt-agnoster-master.tar.gz
zsh-prompt-agnoster-master.tar.bz2
zsh-prompt-agnoster-master.zip
use variables for utf8 symbols instead of using them directlyHEADmaster
-rw-r--r--agnoster.zsh-theme40
1 files changed, 28 insertions, 12 deletions
diff --git a/agnoster.zsh-theme b/agnoster.zsh-theme
index 5ebd689..0bc1c45 100644
--- a/agnoster.zsh-theme
+++ b/agnoster.zsh-theme
@@ -6,10 +6,20 @@
# A few utility functions to make it easy and re-usable to draw segmented prompts
CURRENT_BG='NONE'
-SEGMENT_SEPARATOR=''
SSH_BG=green
PRIMARY_FG=black
+# Characters
+SEGMENT_SEPARATOR="\ue0b0" # 
+PLUSMINUS="\u00b1" # ±
+BRANCH="\ue0a0" # 
+DETACHED="\u27a6" # ➦
+#CROSS="\u2718" # ✘
+CROSS="\u274C" # ❌
+LIGHTNING="\u26a1" # ⚡
+GEAR="\u2699" # ⚙
+ARROW="\u2197" # ↗
+STAR="\u2217" # ∗
# Begin a segment
# Takes two arguments, background and foreground. Both can be omitted,
@@ -52,46 +62,52 @@ prompt_context() {
# Git: branch/detached head, dirty status
prompt_git() {
- local ref dirty
+ local color ref dirty
if $(git rev-parse --is-inside-work-tree 2> /dev/null); then
if [[ -n $(git status -s --ignore-submodules=dirty 2> /dev/null) ]]; then
- prompt_segment yellow black
+ color=yellow
else
- prompt_segment green black
+ color=green
fi
- git diff --no-ext-diff --ignore-submodules --quiet --exit-code || dirty='∗'
+ git diff --no-ext-diff --ignore-submodules --quiet --exit-code || dirty="$STAR"
- ref=$(git symbolic-ref HEAD 2> /dev/null) || ref="➦ $(git show-ref --head -s --abbrev | head -n1 2> /dev/null)"
+ ref=$(git symbolic-ref HEAD 2> /dev/null) || ref="$DETACHED $(git show-ref --head -s --abbrev | head -n1 2> /dev/null)"
if git rev-parse --quiet --verify HEAD >/dev/null; then
- git diff-index --cached --quiet --ignore-submodules HEAD -- || index='±'
+ git diff-index --cached --quiet --ignore-submodules HEAD -- || index="$PLUSMINUS"
else
index="#"
fi
if $(git status -b --porcelain | grep '\[ahead' &> /dev/null); then
- push='↗'
+ push="$ARROW"
fi
+ prompt_segment $color $PRIMARY_FG
echo -n "${ref/refs\/heads\//}${dirty}${index}${push}"
fi
}
+# Dir: current working directory
prompt_dir() {
- prompt_segment blue black '%~'
+ prompt_segment blue $PRIMARY_FG '%~'
}
+# Status:
+# - was there an error
+# - am I root
+# - are there background jobs?
prompt_status() {
local symbols
symbols=()
- [[ $(jobs -l | wc -l) -gt 0 ]] && symbols+="%{%F{cyan}%}⚙"
+ [[ $(jobs -l | wc -l) -gt 0 ]] && symbols+="%{%F{cyan}%}$GEAR"
- [[ -n "$symbols" ]] && prompt_segment black default "$symbols"
+ [[ -n "$symbols" ]] && prompt_segment $PRIMARY_FG default "$symbols"
}
prompt_vi_mode() {
- [[ "$KEYMAP" == "vicmd" ]] && prompt_segment magenta default "❌"
+ [[ "$KEYMAP" == "vicmd" ]] && prompt_segment cyan $PRIMARY_FG "$CROSS"
}
prompt_agnoster_setup () {