From a00dbb2962d9be20b67245bdddbb71eb2b2223a2 Mon Sep 17 00:00:00 2001 From: timfeirg Date: Mon, 30 Nov 2015 08:39:01 +0800 Subject: [PATCH] add BULLETTRAIN_GIT_COLORIZE_DIRTY to show yellow BG when git repo is dirty this feature is borrowed from agnoster https://gist.github.com/agnoster/3712874#file-agnoster-zsh-theme-L82 --- README.md | 1 + bullet-train.zsh-theme | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/README.md b/README.md index d68a3e4..aa9777c 100644 --- a/README.md +++ b/README.md @@ -190,6 +190,7 @@ or don't want to see. All options must be overridden in your **.zshrc** file. |Variable|Default|Meaning |--------|-------|-------| |`BULLETTRAIN_GIT_SHOW`|`true`|Show/hide that segment +|`BULLETTRAIN_GIT_COLORIZE_DIRTY`|`false`|Set BULLETTRAIN_GIT_BG to yellow in dirty state |`BULLETTRAIN_GIT_BG`|`white`|Background color |`BULLETTRAIN_GIT_FG`|`black`|Foreground color |`BULLETTRAIN_GIT_EXTENDED`|`true`| diff --git a/bullet-train.zsh-theme b/bullet-train.zsh-theme index b19a521..8c81bf1 100644 --- a/bullet-train.zsh-theme +++ b/bullet-train.zsh-theme @@ -134,6 +134,9 @@ fi if [ ! -n "${BULLETTRAIN_GIT_SHOW+1}" ]; then BULLETTRAIN_GIT_SHOW=true fi +if [ ! -n "${BULLETTRAIN_GIT_COLORIZE_DIRTY+1}" ]; then + BULLETTRAIN_GIT_COLORIZE_DIRTY=false +fi if [ ! -n "${BULLETTRAIN_GIT_BG+1}" ]; then BULLETTRAIN_GIT_BG=white fi @@ -290,6 +293,9 @@ prompt_git() { repo_path=$(git rev-parse --git-dir 2>/dev/null) if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then + if [[ $BULLETTRAIN_GIT_COLORIZE_DIRTY == true && $(git status --porcelain --ignore-submodules) ]]; then + BULLETTRAIN_GIT_BG=yellow + fi prompt_segment $BULLETTRAIN_GIT_BG $BULLETTRAIN_GIT_FG if [[ $BULLETTRAIN_GIT_EXTENDED == true ]]; then