Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add check for stashes to prompt.sh. #35

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ end of the same file you pasted the installation code into earlier.
#### Mac OS X

```bash
export PS1="\u@\h \W \[\$txtcyn\]\$git_branch\[\$txtred\]\$git_dirty\[\$txtrst\]\$ "
export PS1="\u@\h \W \[\$txtcyn\]\$git_branch\[\$txtred\]\$git_dirty\$git_stash\[\$txtrst\]\$ "
```

Optionally, if you want a nice pretty prompt when using `sudo -s`, also add
Expand All @@ -81,19 +81,19 @@ export SUDO_PS1="\[$bakred\]\u@\h\[$txtrst\] \w\$ "
Standard:

```bash
export PS1="\${debian_chroot:+(\$debian_chroot)}\u@\h:\w \[$txtcyn\]\$git_branch\[$txtred\]\$git_dirty\[$txtrst\]\$ "
export PS1="\${debian_chroot:+(\$debian_chroot)}\u@\h:\w \[$txtcyn\]\$git_branch\[$txtred\]\$git_dirty\$git_stash\[$txtrst\]\$ "
```

Colorized:

```bash
export PS1="\${debian_chroot:+(\$debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\] \[$txtcyn\]\$git_branch\[$txtred\]\$git_dirty\[$txtrst\]\$ "
export PS1="\${debian_chroot:+(\$debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\] \[$txtcyn\]\$git_branch\[$txtred\]\$git_dirty\$git_stash\[$txtrst\]\$ "
```

#### Windows

```bash
export PS1="\[\033]0;$MSYSTEM:\w\007\033[32m\]\u@\h:\[\033[33m\w \[$txtcyn\]\$git_branch\[$txtred\]\$git_dirty\[$txtrst\]\033[0m\]\$ "
export PS1="\[\033]0;$MSYSTEM:\w\007\033[32m\]\u@\h:\[\033[33m\w \[$txtcyn\]\$git_branch\[$txtred\]\$git_dirty\$git_stash\[$txtrst\]\033[0m\]\$ "
```

## Updating
Expand Down
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