diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2017-03-18 14:14:35 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2017-03-18 14:14:35 -0300 |
commit | 125c13eb7c962dbd8670967c2b352fcccb8b8675 (patch) | |
tree | 55dd9f96c58dd9da572fee2007689b1e0924ac1c | |
parent | 5f603c504f949be303f44990f5081438f01b41f6 (diff) | |
download | shellprompt-125c13eb7c962dbd8670967c2b352fcccb8b8675.tar.gz shellprompt-125c13eb7c962dbd8670967c2b352fcccb8b8675.tar.bz2 |
Avoid git pw3nage
-rwxr-xr-x | files/prompt | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/files/prompt b/files/prompt index e580ded..02f0d83 100755 --- a/files/prompt +++ b/files/prompt @@ -35,8 +35,17 @@ command_prompt() { local base_prompt="${status_color}${exit_status}${COLOR_NONE} ${COLOR_CYAN}\D{%Y%m%d %H:%M:%S}${COLOR_NONE} ${COLOR_CYAN}${debian_chroot:+($debian_chroot) }${COLOR_NONE}${COLOR_YELLOW}\u@\h${COLOR_NONE}:${COLOR_CYAN}\w" # Check if completion is available - if type __git_ps1 &> /dev/null; then - PS1="${base_prompt}$(__git_ps1 " (%s)")${COLOR_NONE} \\$ " + # See https://github.com/njhartwell/pw3nage + #if type __git_ps1 &> /dev/null; then + if [ -x "/usr/bin/git" ]; then + #PS1="${base_prompt}$(__git_ps1 " (%s)")${COLOR_NONE} \\$ " + branch="`/usr/bin/git branch 2> /dev/null | grep '^* ' | sed -e 's/\* //' -e 's/ $//'`" + + if [ ! -z "$branch" ]; then + branch=" (${branch//[^a-z0-9\/]/-})" + fi + + PS1="${base_prompt}$branch${COLOR_NONE} \\$ " else PS1="${base_prompt}${COLOR_NONE} \\$ " fi |