From 41aa8fe8257feef2afc5690eed3f83d44963f326 Mon Sep 17 00:00:00 2001 From: oGre Date: Thu, 8 Oct 2015 20:31:52 +0200 Subject: [PATCH] Unset the new variable. Documentation added in README.md Removed unexpected token warning. --- README.md | 8 +++++++- gitprompt.sh | 4 +++- themes/Default.bgptheme | 1 + 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 278de6f..fba7bf1 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ The prompt may look like the following: By default, the general appearance of the prompt is:: - ( |) + ( |) The symbols are as follows: @@ -71,6 +71,10 @@ The symbols are as follows: - ``✚n``: there are ``n`` changed but *unstaged* files - ``…n``: there are ``n`` untracked files - ``⚑n``: there are ``n`` stash entries +- Upstream branch + - Shows the remote tracking branch + - Disabled by default + - Enable by setting GIT_PROMPT_SHOW_UPSTREAM=1 - Branch Tracking Symbols - ``↑n``: ahead of remote by ``n`` commits - ``↓n``: behind remote by ``n`` commits @@ -118,6 +122,8 @@ git clone https://github.com/magicmonty/bash-git-prompt.git .bash-git-prompt GIT_PROMPT_ONLY_IN_REPO=1 # GIT_PROMPT_FETCH_REMOTE_STATUS=0 # uncomment to avoid fetching remote status + + # GIT_PROMPT_SHOW_UPSTREAM=1 # uncomment to show upstream tracking branch # GIT_PROMPT_START=... # uncomment for custom prompt start sequence # GIT_PROMPT_END=... # uncomment for custom prompt end sequence diff --git a/gitprompt.sh b/gitprompt.sh index d76987b..4aad850 100755 --- a/gitprompt.sh +++ b/gitprompt.sh @@ -435,6 +435,7 @@ function updatePrompt() { export __GIT_PROMPT_IGNORE_STASH=${GIT_PROMPT_IGNORE_STASH} export __GIT_PROMPT_SHOW_UPSTREAM=${GIT_PROMPT_SHOW_UPSTREAM} + local -a git_status_fields git_status_fields=($("$__GIT_STATUS_CMD" 2>/dev/null)) @@ -533,7 +534,8 @@ function is_function { #Helper function that truncates $PWD depending on window width function gp_truncate_pwd { - local newPWD="${PWD/#$HOME/~}" + local tilde="~" + local newPWD="${PWD/#${HOME}/${tilde}}" local pwdmaxlen=$((${COLUMNS:-80}/3)) [ ${#newPWD} -gt $pwdmaxlen ] && newPWD="...${newPWD:3-$pwdmaxlen}" echo -n "$newPWD" diff --git a/themes/Default.bgptheme b/themes/Default.bgptheme index 8ed02fa..057038a 100644 --- a/themes/Default.bgptheme +++ b/themes/Default.bgptheme @@ -17,6 +17,7 @@ unset_git_prompt_colors() { unset GIT_PROMPT_COMMAND_OK unset GIT_PROMPT_COMMAND_FAIL unset GIT_PROMPT_VIRTUALENV + unset GIT_PROMPT_UPSTREAM unset GIT_PROMPT_START_USER unset GIT_PROMPT_START_ROOT unset GIT_PROMPT_END_USER