Skip to content

Instantly share code, notes, and snippets.

@KristobalJunta
Created April 16, 2017 20:37
Show Gist options
  • Save KristobalJunta/64540e08835da2c7bd7d499f8022273d to your computer and use it in GitHub Desktop.
Save KristobalJunta/64540e08835da2c7bd7d499f8022273d to your computer and use it in GitHub Desktop.
#!/bin/sh
TODO_DIR=~/todos/
TODO_PREFIX="TODO-"
mkdir -p $TODO_DIR
cd $TODO_DIR
# copy most recent* TODO file
# *recent = using filename, not last edited! So filenames need to be in a sane date format, like YYYY-MM-DD
RECENT_TODO=`ls -1 | head -n1`
# use this if you want to use last edited instead
# RECENT_TODO=`ls -1t | head -n1`
# %F == YYYY-MM-DD
TODO_SUFFIX=`date +"%F"`
TODO_FILENAME="${TODO_PREFIX}${TODO_SUFFIX}"
# if there is an existing TODO, then copy from that...
if [ -e "${RECENT_TODO}" ]; then
cp ${RECENT_TODO} ${TODO_FILENAME}
else
# ...otherwise, just create new TODO
echo "TODO\n-do the thing\n\nAccomplished\n-created TODO\n" > ${TODO_FILENAME}
fi
echo "New todo created:\n${TODO_DIR}${TODO_FILENAME}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment