Created
May 20, 2011 19:25
-
-
Save austintaylor/983591 to your computer and use it in GitHub Desktop.
My todo file hack
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[core] | |
excludesfile = /Users/austin/.gitignore |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.todo |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source .todo.profile |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Open my private todo file | |
nmap <leader>t :sp .todo<CR> | |
" Close my private todo file on save | |
au BufWritePost .todo bd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
All files are in my home directory, if that wasn't obvious.
,t
to open.⌘s
to dismiss.