From: Alexander Barton Date: Wed, 21 Jul 2010 12:17:26 +0000 (+0200) Subject: Add GIT branch name to shell prompt, if in a repository directory X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=ConfigScripts.git;a=commitdiff_plain;h=dd512df814a6faeaa7d13cb581b13ab9af8451e4 Add GIT branch name to shell prompt, if in a repository directory This patch changes the prompt format for displaying the current chroot name as well: () -> [] --- diff --git a/sys/bashrc b/sys/bashrc index 544e6c1..77bc837 100644 --- a/sys/bashrc +++ b/sys/bashrc @@ -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 ] \