fixed todo count bug

todo module would still show up if todo.txt was installed but not
used with a blank value. Added a sanity check to make sure we actally
get a number back from todo.txt and do nothing if we dont
pull/90/head
rjorgenson 2011-06-29 01:27:24 -07:00
parent 2b4f94a804
commit 0b218c4eb2
1 changed files with 11 additions and 4 deletions

View File

@ -43,11 +43,18 @@ is_vim_shell() {
fi fi
} }
function is_integer() { # helper function for todo-txt-count
[ "$1" -eq "$1" ] > /dev/null 2>&1
return $?
}
todo_txt_count() { todo_txt_count() {
if `hash todo.sh 2>&-`; then if `hash todo.sh 2>&-`; then # is todo.sh installed
count=`todo.sh ls | egrep "TODO: [0-9]+ of ([0-9]+) tasks shown" | awk '{ print $4 }'` count=`todo.sh ls | egrep "TODO: [0-9]+ of ([0-9]+) tasks shown" | awk '{ print $4 }'`
if is_integer $count; then # did we get a sane answer back
echo "$BRACKET_COLOR[${STRING_COLOR}T:$count$BRACKET_COLOR]$normal" echo "$BRACKET_COLOR[${STRING_COLOR}T:$count$BRACKET_COLOR]$normal"
fi fi
fi
} }
modern_scm_prompt() { modern_scm_prompt() {