From dd512df814a6faeaa7d13cb581b13ab9af8451e4 Mon Sep 17 00:00:00 2001 From: Alexander Barton Date: Wed, 21 Jul 2010 14:17:26 +0200 Subject: [PATCH] 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: () -> [] --- sys/bashrc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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 ] \ -- 2.39.2