Skip to content

Commit

Permalink
Add check for stashes to prompt.sh.
Browse files Browse the repository at this point in the history
  • Loading branch information
orehmane committed Sep 13, 2023
1 parent df8f218 commit 373db43
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions prompt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,31 @@ find_git_branch() {
if [[ "$branch" == "HEAD" ]]; then
branch='detached*'
fi
git_branch="($branch)"
git_branch=" ($branch) "
else
git_branch=""
git_branch=" "
fi
}

find_git_dirty() {
local status=$(git status --porcelain 2> /dev/null)
if [[ "$status" != "" ]]; then
git_dirty='*'
git_dirty='* '
else
git_dirty=''
fi
}

PROMPT_COMMAND="find_git_branch; find_git_dirty; $PROMPT_COMMAND"
find_git_stashes() {
local stash=$(git stash list 2> /dev/null)
if [[ "$stash" != "" ]]; then
git_stash='S '
else
git_stash=''
fi
}

PROMPT_COMMAND="find_git_branch; find_git_dirty; find_git_stashes; $PROMPT_COMMAND"

# Default Git enabled prompt with dirty state
# export PS1="\u@\h \w \[$txtcyn\]\$git_branch\[$txtred\]\$git_dirty\[$txtrst\]\$ "
Expand Down

0 comments on commit 373db43

Please sign in to comment.