-
-
Save anonymous/9027570 to your computer and use it in GitHub Desktop.
This file contains 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
#!/bin/sh | |
TASK_DIR=$HOME/tasks | |
help () { | |
echo "Valid subcommands: create, ls, rm, cat, edit" | |
} | |
nth () { | |
ls $TASK_DIR | sed "$1q;d" | |
} | |
taskcreate () { | |
ESCAPE=$(printf "%q" $1) | |
FILENAME="${*}.txt" | |
touch "$TASK_DIR/$FILENAME" | |
} | |
taskls () { | |
ls $TASK_DIR | cat -n | sed "s/\..*//g" | |
} | |
taskrm () { | |
N=$1 | |
if [ -z $N ] ; then | |
echo "** TASKS **" | |
taskls | |
read -p "Select a task number: " N | |
fi | |
F=$(nth $N) | |
rm "$TASK_DIR/$F" | |
} | |
taskcat () { | |
N=$1 | |
if [ -z $N ] ; then | |
echo "** TASKS **" | |
taskls | |
read -p "Select a task number: " N | |
fi | |
F=$(nth $N) | |
cat "$TASK_DIR/$F" | |
} | |
taskedit () { | |
N=$1 | |
if [ -z $N ] ; then | |
echo "** TASKS **" | |
taskls | |
read -p "Select a task number: " N | |
fi | |
F=$(nth $N) | |
$EDITOR "$TASK_DIR/$F" | |
} | |
case $1 in | |
cat) taskcat $2 | |
;; | |
rm) taskrm $2 | |
;; | |
ls) taskls | |
;; | |
edit) taskedit $2 | |
;; | |
create) taskcreate $2 | |
;; | |
*) help | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment