-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathedit
executable file
·36 lines (31 loc) · 862 Bytes
/
edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/sh
#
# Another 'edit' add-on for todo.sh
#
# Author: Jon Smajda
# License: GPL, http://www.gnu.org/copyleft/gpl.html
# URL: http://github.com/smajda/todo.actions.d
action=$1
shift
[ "$action" = "usage" ] && {
echo " `basename $0` [FILE] [editor arguments]"
echo " Open \$TODO_DIR/FILE in \$EDITOR"
echo " If left empty, opens $TODO_FILE"
echo " Supports vim's +n 'open on line n' feature"
echo " See $0"
echo ""
exit
}
# if no arguments, open default todo file in EDITOR
if [[ -z "${@}" ]]; then
"$EDITOR" "$TODO_FILE"
else
# if argument starts with a "+" open up todo on that line in vi
if [[ `echo "$@" | grep ^"\+"` ]]; then
"$EDITOR" "$TODO_FILE" "$@"
# otherwise, pass all of $@ to vi (separate file and/or line no)
else
"$EDITOR" "$TODO_DIR"/"$@"
fi
fi
exit