You are not logged in.
Pages: 1
This one is even simpler than Ghost's
As in, less functional, but it does what I need it to do
#!/bin/zsh
flag=$1
arg=$2
todofile="/home/barrucadu/docs/main.todo"
function append()
{
echo "* TODO $arg" >> $todofile
}
function delete()
{
sed -i "$arg d" $todofile
}
function toggle()
{
sed -i "$arg s/^\* TODO/\* ODOT/" $todofile
sed -i "$arg s/^\* DONE/\* ENODE/" $todofile
sed -i "$arg s/^\* ENODE/\* TODO/" $todofile
sed -i "$arg s/^\* ODOT/\* DONE/" $todofile
}
function clean()
{
sed -i "/^\* DONE .*$/d" $todofile
}
function listall()
{
grep -n -e "^\* \(TODO\|DONE\)" $todofile
}
function listtodo()
{
grep -n "^\* TODO" $todofile
}
function listfinished()
{
grep -n "^\* DONE" $todofile
}
function help()
{
echo "Usage: todo [flag] [arg]"
echo
echo "---"
echo
echo "A simple todo-file manager, which manipulates todo files in a subset of the Emacs Org-mode format."
echo
echo "---"
echo
echo "Flags:"
echo " a - Append new entry."
echo " arg = Description"
echo
echo " d - Delete existing entry."
echo " arg = Line number"
echo
echo " t - Toggle an entry's todo/done state.."
echo " arg = Line number"
echo
echo " c - Clean finished entries from list."
echo " l - List entries."
echo " lt - List entries marked as to do."
echo " lf - List entries marked as finished."
echo " h - Display this text."
echo
}
case "$flag" in
"a")
append
;;
"d")
delete
;;
"t")
toggle
;;
"c")
clean
;;
"l")
listall
;;
"lt")
listtodo
;;
"lf")
listfinished
;;
"h")
help
;;
"")
help
;;
*)
echo "Error: unknown flag '$flag'."
return 1
;;
esac
return 0
It's a simple little script, running with no args will give you a help message. You'll probably want to edit the $todofile variable to point to your todo file. Also, you can do cool things like this:
todo lt | sed "s/^.* TODO /To Do: /" | sort -R | head -n1
Which I've added to my .zshrc, so now, upon opening a terminal, I see a random thing I have yet to do. Hopefully this will spur me to action.
As you can probably tell from the name of my todo file (main.todo), I've considered support for multiple todo lists. But I've decided that if I do that, it'll be in one file, but using org-mode tags to separate the lists. I don't think I'll add the feature for a while (if ever) though.
Offline
HEY! We should start a todo-off, like the infamous 'arch is best' thread.
I've got an even simpler one in my zshrc
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
}
Yet even LESS functional.
archlinux - please read this and this — twice — then ask questions.
--
http://rsontech.net | http://github.com/rson
Offline
Well, yours does support deleting things by entering the todo text, which mine doesn't. So it could be considered more functional in that way
Offline
Ok, so it's not as simple, but it's still cli and pretty powerful for how small it is....the todo.txt script written by one of the Lifehacker.com editors. Works great and is pretty hackable if you so desire....
Scott
Offline
Hey,
really liked that rson451's simple todo thingy. But deleting entries is kinda sketchy. And i like my entries numbered. And i like to delete my entries by that number instead of relying on some regex. So here's my version:
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')
rm $HOME/.todo # i needed that, because it didn't wanted to echo into an existing file.
echo $todo > $HOME/.todo
;;
"search")
grep -ni --color=never $2 $HOME/.todo | sed -e 's/:/: /'
;;
esac
}
Edit: added simple search function
Last edited by rich_o (2009-07-26 14:32:31)
Offline
Ok, so it's not as simple, but it's still cli and pretty powerful for how small it is....the todo.txt script written by one of the Lifehacker.com editors. Works great and is pretty hackable if you so desire....
Scott
That script looks great, thanks
Edit: It's even in AUR
Last edited by jordz (2009-07-26 12:27:41)
Offline
firecat53 wrote:Ok, so it's not as simple, but it's still cli and pretty powerful for how small it is....the todo.txt script written by one of the Lifehacker.com editors. Works great and is pretty hackable if you so desire....
Scott
That script looks great, thanks
Edit: It's even in AUR
Homemade is way cooler ! I made one in haskell a time ago , it also supports searching. But i am thinking of rewriting it and writing one in python
What would be more cooler is to have the todolist editor talk with your server / a website so you can access it from the whole word
Last edited by jelly (2009-07-26 13:18:45)
Offline
Pages: 1