Skip to content

Instantly share code, notes, and snippets.

@austintaylor
Created May 20, 2011 19:25
Show Gist options
  • Save austintaylor/983591 to your computer and use it in GitHub Desktop.
Save austintaylor/983591 to your computer and use it in GitHub Desktop.
My todo file hack
[core]
excludesfile = /Users/austin/.gitignore
source .todo.profile
function t_list() {
awk '{ printf "%3s. %s\n", NR, $0 }' .todo
}
function t_show() {
t_list | sed "$1p;d"
}
function t_get() {
sed "$1p;d" .todo
}
function t_add() {
echo $1 >> .todo
}
function t_rm() {
sed "$1d" .todo > .todo.out
mv .todo.out .todo
}
function t_git() {
git $1 "`t_get $2`"
}
function t() {
if [[ $# -eq 0 ]]; then
t_list
fi
if [[ $# -ne 0 ]]; then
case "$1" in
list)
t_list
;;
ci)
t_git ci $2
t_rm $2
;;
cia)
t_git cia $2
t_rm $2
;;
a)
t_add "$2"
t_list
;;
add)
t_add "$2"
t_list
;;
rm)
t_rm $2
t_list
;;
show)
t_show ${2:-1}
;;
[0-9]*)
t_show $1
;;
*)
echo "Cannot understand command: $1"
;;
esac
fi
}
" Open my private todo file
nmap <leader>t :sp .todo<CR>
" Close my private todo file on save
au BufWritePost .todo bd
@austintaylor
Copy link
Author

All files are in my home directory, if that wasn't obvious. ,t to open. ⌘s to dismiss.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment