BEIKE blog

備忘録です

Ubuntu bashのプロンプトにgit branchを表示する

以下のコードをbashrcにコピペして、sourceすれば

スグに使える。

if [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
fi
if [ -f /etc/bash_completion.d/git-prompt ]; then
    export PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w$(__git_ps1)\[\033[00m\](\t)\$ '
else
    export PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi