]> arthur.barton.de Git - ConfigScripts.git/commitdiff
Add GIT branch name to shell prompt, if in a repository directory
authorAlexander Barton <alex@barton.de>
Wed, 21 Jul 2010 12:17:26 +0000 (14:17 +0200)
committerAlexander Barton <alex@barton.de>
Wed, 21 Jul 2010 12:17:26 +0000 (14:17 +0200)
This patch changes the prompt format for displaying the current chroot
name as well: (<name>) -> [<name>]

sys/bashrc

index 544e6c156d07ccd0fefcae65e458b134e2633b09..77bc8372866f75732f7d23e448c8a32282e5c47e 100644 (file)
@@ -32,10 +32,13 @@ sshtmp() {
 }
 
 # Shell prompt
-prefix="${chroot_name:+($chroot_name)}"
 [ "$UID" -eq 0 ] \
-       && PS1="${prefix}\h:\w \\\$ " \
-       || PS1="${prefix}\u@\h:\w \\\$ "
+       && PS1="\h:\w \\\$ " \
+       || PS1="\u@\h:\w \\\$ "
+if [ "\$(type -t __git_ps1)" ]; then
+       PS1="\$(__git_ps1 '(%s) ')$PS1"
+fi
+PS1="${chroot_name:+[$chroot_name] }$PS1"
 
 # Enable bash completion, if available
 [ -z "$BASH_COMPLETION" -a -r /etc/bash_completion ] \