Merge pull request #32 from rsteuerw/master

Show number of stash entries in bash prompt
master
Martin Gondermann 12 years ago
commit b54437f917
  1. 2
      README.md
  2. 9
      gitprompt.sh
  3. 7
      gitstatus.py

@ -17,6 +17,7 @@ The prompt may look like the following:
* ``(status|●2)``: on branch ``status``, 2 files staged
* ``(master|✚7…)``: on branch ``master``, 7 files changed, some files untracked
* ``(master|✖2✚3)``: on branch ``master``, 2 conflicts, 3 files changed
* ``(master|⚑2)``: on branch ``master``, 2 stash entries
* ``(experimental↓2↑3|✔)``: on branch ``experimental``; your branch has diverged by 3 commits, remote by 2 commits; the repository is otherwise clean
* ``(:70c2952|✔)``: not on any branch; parent commit has hash ``70c2952``; the repository is otherwise clean
@ -34,6 +35,7 @@ The symbols are as follows:
- ``✖n``: there are ``n`` unmerged files
- ``✚n``: there are ``n`` changed but *unstaged* files
- ``…n``: there are ``n`` untracked files
- ``⚑n``: there are ``n`` stash entries
- Branch Tracking Symbols
- ``↑n``: ahead of remote by ``n`` commits
- ``↓n``: behind remote by ``n`` commits

@ -53,6 +53,7 @@ function git_prompt_config()
GIT_PROMPT_CHANGED="${Blue}"
GIT_PROMPT_REMOTE=" "
GIT_PROMPT_UNTRACKED="…"
GIT_PROMPT_STASHED="⚑ "
GIT_PROMPT_CLEAN="${BoldGreen}"
# Various variables you might want for your PS1 prompt instead
@ -128,6 +129,7 @@ function updatePrompt() {
local GIT_PROMPT_CHANGED
local GIT_PROMPT_REMOTE
local GIT_PROMPT_UNTRACKED
local GIT_PROMPT_STASHED
local GIT_PROMPT_CLEAN
local PROMPT_START
local PROMPT_END
@ -151,7 +153,8 @@ function updatePrompt() {
local GIT_CONFLICTS=${GitStatus[3]}
local GIT_CHANGED=${GitStatus[4]}
local GIT_UNTRACKED=${GitStatus[5]}
local GIT_CLEAN=${GitStatus[6]}
local GIT_STASHED=${GitStatus[6]}
local GIT_CLEAN=${GitStatus[7]}
if [[ -n "${GitStatus}" ]]; then
local STATUS=" ${GIT_PROMPT_PREFIX}${GIT_PROMPT_BRANCH}${GIT_BRANCH}${ResetColor}"
@ -177,6 +180,10 @@ function updatePrompt() {
STATUS="${STATUS}${GIT_PROMPT_UNTRACKED}${GIT_UNTRACKED}${ResetColor}"
fi
if [ "${GIT_STASHED}" -ne "0" ]; then
STATUS="${STATUS}${GIT_PROMPT_STASHED}${GIT_STASHED}${ResetColor}"
fi
if [ "${GIT_CLEAN}" -eq "1" ]; then
STATUS="${STATUS}${GIT_PROMPT_CLEAN}"
fi

@ -67,7 +67,11 @@ status_lines = Popen(['git','status','-s','-uall'],stdout=PIPE).communicate()[0]
untracked_lines = [a for a in status_lines if a.startswith("??")]
nb_untracked = len(untracked_lines)
untracked = str(nb_untracked)
if not nb_changed and not nb_staged and not nb_U and not nb_untracked:
stashes = Popen(['git','stash','list'],stdout=PIPE).communicate()[0].splitlines()
nb_stashed = len(stashes)
stashed = str(nb_stashed)
if not nb_changed and not nb_staged and not nb_U and not nb_untracked and not nb_stashed:
clean = '1'
else:
clean = '0'
@ -115,5 +119,6 @@ out = '\n'.join([
conflicts,
changed,
untracked,
stashed,
clean])
Print(out)

Loading…
Cancel
Save