Thursday, August 4, 2011

Using the git completion bash script

http://repo.or.cz/w/git.git/blob_plain/HEAD:/contrib/completion/git-completion.bash

Within the file, the description is listed here:

3) Consider changing your PS1 to also show the current branch:
#         Bash: PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ '

PS1 is the bash custom prompt:
http://www.cyberciti.biz/tips/howto-linux-unix-bash-shell-setup-prompt.html
The default bash prompt is usually:
echo $PS1
${debian_chroot:+($debian_chroot)}\u@\h:\w\$

...which is defined in /etc/bash.bashrc:
# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
    debian_chroot=$(cat /etc/debian_chroot)
fi

The ${debian_chroot} is defined in /etc/bash.bashrc if the directory is chrooted, which it normally isn't so is left blank. The \u @ \h refers to the username and the host, the \w refers to the current working directory, and \$ will show '$' if the UID is not 0 (in which case, will show '#' to indicate root-level access)

No comments:

Post a Comment