From 0b218c4eb23c98b8adb749491a160e5916804d80 Mon Sep 17 00:00:00 2001 From: rjorgenson Date: Wed, 29 Jun 2011 01:27:24 -0700 Subject: [PATCH] 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 --- themes/rjorgenson/rjorgenson.theme.bash | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/themes/rjorgenson/rjorgenson.theme.bash b/themes/rjorgenson/rjorgenson.theme.bash index 1d4c261..c6dfe6e 100644 --- a/themes/rjorgenson/rjorgenson.theme.bash +++ b/themes/rjorgenson/rjorgenson.theme.bash @@ -43,11 +43,18 @@ is_vim_shell() { fi } +function is_integer() { # helper function for todo-txt-count + [ "$1" -eq "$1" ] > /dev/null 2>&1 + return $? +} + todo_txt_count() { - if `hash todo.sh 2>&-`; then - count=`todo.sh ls | egrep "TODO: [0-9]+ of ([0-9]+) tasks shown" | awk '{ print $4 }'` - echo "$BRACKET_COLOR[${STRING_COLOR}T:$count$BRACKET_COLOR]$normal" - fi + 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 }'` + if is_integer $count; then # did we get a sane answer back + echo "$BRACKET_COLOR[${STRING_COLOR}T:$count$BRACKET_COLOR]$normal" + fi + fi } modern_scm_prompt() { -- 2.17.1