Skip to content

Instantly share code, notes, and snippets.

@ear7h
Created June 15, 2021 19:13
Show Gist options
  • Save ear7h/bfa443faa491cdaf7fe256db1424c85b to your computer and use it in GitHub Desktop.
Save ear7h/bfa443faa491cdaf7fe256db1424c85b to your computer and use it in GitHub Desktop.
A command line todo application
#!/usr/bin/env sh
alias isodate='date +"%Y-%m-%d"'
if [ $# -eq 0 ]; then
cat ~/todo/$(isodate).txt
exit 0
fi
if [ $# -gt 1 ]; then
echo "invalid args" 1>&2
echo "usage: todo carry|vim" 1>&2
exit 1
fi
case $1 in
"carry")
cat $(ls -r ~/todo/) | grep -v "[x]" >> ~/todo/$(isodate).txt
awk -i inplace '{ if (!seen[$0]++) print }' ~/todo/$(isodate).txt
cat ~/todo/$(isodate).txt
;;
"vim")
vim ~/todo/$(isodate).txt
;;
*)
echo "invalid args" 1>&2
echo "usage: todo carry|vim" 1>&2
exit 1
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment