From 5a72f5aff20a93452f076557a06f504d2c370dcb Mon Sep 17 00:00:00 2001 From: ogr3 Date: Fri, 24 Jan 2014 11:18:55 +0100 Subject: [PATCH 1/4] Associative arrays does not work on Bash 3 (OS X for instance). Change to ordinary variables to be more compatible. --- gitstatus.sh | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/gitstatus.sh b/gitstatus.sh index d290e07..4b199ef 100755 --- a/gitstatus.sh +++ b/gitstatus.sh @@ -6,10 +6,9 @@ # Alan K. Stebbens [http://github.com/aks] # change those symbols to whatever you prefer -declare -a symbols -symbols['ahead']='↑·' -symbols['behind']='↓·' -symbols['prehash']=':' +symbols_ahead='↑·' +symbols_behind='↓·' +symbols_prehash=':' gitsym=`git symbolic-ref HEAD` @@ -52,7 +51,7 @@ if [[ -z "$branch" ]]; then if [[ -n "$tag" ]]; then branch="$tag" else - branch="${symbols['prehash']}`git rev-parse --short HEAD`" + branch="${symbols_prehash}`git rev-parse --short HEAD`" fi else remote_name=`git config branch.${branch}.remote` @@ -73,10 +72,10 @@ else num_ahead=`count_lines "^>"` num_behind=$(( num_revs - num_ahead )) if (( num_behind > 0 )) ; then - remote="${remote}${symbols['behind']}${num_behind}" + remote="${remote}${symbols_behind}${num_behind}" fi if (( num_ahead > 0 )) ; then - remote="${remote}${symbols['ahead']}${num_ahead}" + remote="${remote}${symbols_ahead}${num_ahead}" fi fi if [[ -z "$remote" ]] ; then From 5c49f42858bfeb6516a5fd87e8b38778bc53553f Mon Sep 17 00:00:00 2001 From: Martin Gondermann Date: Fri, 24 Jan 2014 16:53:36 +0100 Subject: [PATCH 2/4] Added sourcing of git_prompt_help.sh to gitprompt.sh --- gitprompt.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gitprompt.sh b/gitprompt.sh index fc21851..f4ca70e 100755 --- a/gitprompt.sh +++ b/gitprompt.sh @@ -253,3 +253,6 @@ else PROMPT_COMMAND=${PROMPT_COMMAND%\;}; # remove trailing semi-colon PROMPT_COMMAND="$PROMPT_COMMAND;setGitPrompt" fi + +git_prompt_dir +source $__GIT_PROMPT_DIR/git-prompt-help.sh From 74f9786745fe991283c3ce540a7a4a082128712b Mon Sep 17 00:00:00 2001 From: Martin Gondermann Date: Fri, 24 Jan 2014 15:56:00 +0000 Subject: [PATCH 3/4] Colorized git-prompt-help with configured colors and symbols --- git-prompt-help.sh | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/git-prompt-help.sh b/git-prompt-help.sh index b9c699b..19d9312 100644 --- a/git-prompt-help.sh +++ b/git-prompt-help.sh @@ -3,7 +3,7 @@ # being displayed. git_prompt_help() { - cat <&2 + cat <|] BRANCH is a branch name, such as "master" or "stage", a tag name, or commit @@ -12,44 +12,46 @@ hash prefixed with ':'. TRACKING indicates how the local branch differs from the remote branch. It can be empty, or one of: - ↑N - ahead of remote by N commits - ↓N - behind remote by N commits - ↓M↑N - branches diverged, other by M commits, yours by N commits + ${GIT_PROMPT_BRANCH}${GIT_PROMPT_REMOTE}↑N${ResetColor} - ahead of remote by N commits + ${GIT_PROMPT_BRANCH}${GIT_PROMPT_REMOTE}↓N${ResetColor} - behind remote by N commits + ${GIT_PROMPT_BRANCH}${GIT_PROMPT_REMOTE}↓M↑N${ResetColor} - branches diverged, other by M commits, yours by N commits LOCALSTATUS is one of the following: - ✔ - repository clean - ●N - N staged files - ✖N - N unmerged files - ✚N - N changed but *unstaged* files - …N - N untracked files - ⚑N - N stash entries + ${GIT_PROMPT_CLEAN}${ResetColor} - repository clean + ${GIT_PROMPT_STAGED}N${ResetColor} - N staged files + ${GIT_PROMPT_CONFLICTS}N${ResetColor} - N conflicted files + ${GIT_PROMPT_CHANGED}N${ResetColor} - N changed but *unstaged* files + ${GIT_PROMPT_UNTRACKED}N${ResetColor} - N untracked files + ${GIT_PROMPT_STASHED}N${ResetColor} - N stash entries See "git_prompt_examples" for examples. EOF } + help_git_prompt() { git_prompt_help ; } git_prompt_examples() { - cat <&2 + cat < Date: Fri, 24 Jan 2014 17:05:12 +0100 Subject: [PATCH 4/4] Fixed Symbols for ahead and behind --- git-prompt-help.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/git-prompt-help.sh b/git-prompt-help.sh index 19d9312..ca6c5de 100644 --- a/git-prompt-help.sh +++ b/git-prompt-help.sh @@ -12,9 +12,9 @@ hash prefixed with ':'. TRACKING indicates how the local branch differs from the remote branch. It can be empty, or one of: - ${GIT_PROMPT_BRANCH}${GIT_PROMPT_REMOTE}↑N${ResetColor} - ahead of remote by N commits - ${GIT_PROMPT_BRANCH}${GIT_PROMPT_REMOTE}↓N${ResetColor} - behind remote by N commits - ${GIT_PROMPT_BRANCH}${GIT_PROMPT_REMOTE}↓M↑N${ResetColor} - branches diverged, other by M commits, yours by N commits + ${GIT_PROMPT_BRANCH}${ResetColor}${GIT_PROMPT_REMOTE}↑·N${ResetColor} - ahead of remote by N commits + ${GIT_PROMPT_BRANCH}${ResetColor}${GIT_PROMPT_REMOTE}↓·N${ResetColor} - behind remote by N commits + ${GIT_PROMPT_BRANCH}${ResetColor}${GIT_PROMPT_REMOTE}↓·M↑·N${ResetColor} - branches diverged, other by M commits, yours by N commits LOCALSTATUS is one of the following: @@ -35,7 +35,7 @@ git_prompt_examples() { cat <