- Clone Git Prompt support
https://github.com/jimeh/git-aware-prompt
to~/.bash/
(~/.bash/git-aware-prompt/
) - Add enclosed Mercurial Prompt support to
~/.bash/
(~/.bash/hg_prompt.sh
) - Integrate both into your
~/.bash_profile
with:
# git prompt
export GITAWAREPROMPT=~/.bash/git-aware-prompt
source "${GITAWAREPROMPT}/main.sh"
# mercurial prompt
source ~/.bash/hg_prompt.sh
# combined prompt
scm_branch() {
if [ -z "$git_branch" ]
then
local _hg_branch=$(hg_branch)
if [ -z "$_hg_branch" ]
then
return
else
echo -n "("$_hg_branch")"
fi
else
echo -n $git_branch
fi
}
scm_dirty() {
if [ -z "$git_dirty" ]
then
local _hg_dirty=$(hg_dirty)
if [ -z "$_hg_dirty" ]
then
return
else
echo -n "$_hg_dirty"
fi
else
echo -n "$git_dirty"
fi
}
# install prompt
export PS1="\u@\h \w \[$txtcyn\]\$(scm_branch)\[$txtred\]\$(scm_dirty)\[$txtrst\]\$ "
Then enjoy seeing directory sensitive prompts when CD'ing into git and hg repos such as: nr@Computer ~/proj/slash (features/main)*$
and nr@Computer ~/proj/editor (cloud/time)!$
. Note the hg support currently feels 'slow'.