bash/prompt @ 2eeb73d76fc8

Add the d alias.
author Steve Losh <steve@stevelosh.com>
date Thu, 21 Jan 2010 09:14:02 -0500
parents b8355d9279d4
children (none)
#!/usr/bin/env bash

D=$'\[\e[0m\]'
GREY=$'\[\e[30;1;40m\]'
PINK=$'\[\e[35;40m\]'
GREEN=$'\[\e[32;40m\]'
ORANGE=$'\[\e[33;40m\]'

hg_ps1() {
  hg prompt "\
{${D} on ${PINK}{branch}}\
{${D} at ${ORANGE}{tags|${D}, ${ORANGE}}}\
{${GREEN}{status|modified|unknown}}{${GREEN}{update}}\
{${D}\npatches: {patches|pre_applied(${ORANGE})|post_applied(${D})|pre_unapplied(${GREY})|post_unapplied(${D})}}\
" 2> /dev/null
}

tasks_ps1() {
    t | wc -l | sed -e's/ *//'
}

render_ps1() {
  echo "\n\
${PINK}\u ${D}at ${ORANGE}\h ${D}in ${GREEN}\w$(hg_ps1)${D}\n\
[$(tasks_ps1)] $([ $VIRTUAL_ENV ] && echo '('`basename $VIRTUAL_ENV`') ' )$ "
}

PROMPT_COMMAND="$(echo "$PROMPT_COMMAND"|sed -e's/PS1="`render_ps1`";//g')"
PROMPT_COMMAND='PS1="`render_ps1`";'"$PROMPT_COMMAND"