Simple Fish Shell-based TODO System
I wanted a small TODO list that only had to be accessible on a single machine. I could just use a text file but I don't want to open an editor or think too much when interacting with the list. A moments thought led me to writing some simple fish shell functions and adding them to
.config/fish/config.fish
:
function todo
echo $argv >> ~/.todo
end
this function appends a message to the TODO log, used like so:
todo write blog post explaining system
Now we need an easy way to read the list:
function ls-todo
cat -n ~/.todo
end
the -n option displays line numbers. These will be useful for specifying entries to remove once we've smashed our goals. The following function deletes a line, given a line number:
function rm-todo
awk "$(printf 'FNR != %s {print $0;}' $argv[1])" ~/.todo > ~/.todo_next
mv ~/.todo_next ~/.todo
end
a final convenience command simply opens an editor on the list:
function ed-todo
hx ~/.todo
end
Now to shame the user into accomplishing the tasks by displaying it back to them whenever an interactive fish shell session starts:
if status is-interactive
ls-todo
end