From 373db43cf84ac1318cc54a7c4ad0c540851d8ed3 Mon Sep 17 00:00:00 2001 From: Omar Rehmane Date: Mon, 16 May 2016 21:24:02 -0700 Subject: [PATCH 1/2] Add check for stashes to prompt.sh. --- prompt.sh | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/prompt.sh b/prompt.sh index 6a737b8..c801ed9 100644 --- a/prompt.sh +++ b/prompt.sh @@ -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\]\$ " From d80bb434d614a547f650818cdd777ac5b95ff816 Mon Sep 17 00:00:00 2001 From: Omar Rehmane Date: Tue, 12 Sep 2023 18:21:19 -0700 Subject: [PATCH 2/2] Update README to include stash in the suggested prompts. --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 73429d8..76a820f 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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