Simple Todo
Jelly in the archlinux irc channel asked for suggestions for a cli todo app, and I offered this to him on a whim. As it turns out, it’s actually pretty damn useful.
todo()
{
if [ -z $1 ]; then
cat $HOME/.todo
return
fi
case $1 in
"add")
echo $2 >> $HOME/.todo
;;
"del")
todo=$(< $HOME/.todo | sed 's/'$2'//;tx;p;:x;d')
echo $todo > $HOME/.todo
;;
esac
}
You can also find this in my zshrc on github.
Edit: rich_o on the archlinux bbs posted a modification to this which allows you to delete tasks by number and search for a task. I’ve began using this mod instead:
todo()
{
if [ -z $1 ]; then
awk '{ i += 1; print i": "$0 }' $HOME/.todo
return
fi
case $1 in
"add")
echo $2 >> $HOME/.todo
;;
"del")
todo=$(< $HOME/.todo | sed "$2"'d')
echo $todo > $HOME/.todo
;;
"search")
grep -ni --color=never $2 $HOME/.todo | sed -e 's/:/: /'
;;
esac
}