Created
January 6, 2020 05:18
-
-
Save mkober/0d12c00e968a0aa1f6954d43f09760f5 to your computer and use it in GitHub Desktop.
EC2 User Profile
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
# fin - command line TODO list | |
# https://medium.com/@sambrin/fin-command-line-todo-list-made-with-30a2346de068 | |
# Notes | |
# 1. Original find didn't work properly on AWS | |
# find ${TASKS_DIR} -not -path '*/\.*' -type f -execdir echo '{}' ';' | nl -s '[] ' -b n | |
BOLD_AND_UNDERLINED="\e[1;4m" | |
GREEN="\e[32m" | |
STANDARD="\e[0m" | |
TODO_LIST_LABEL="\n — — — — — — — — — — — -TODO — — — — — — — — — — — — -\n" | |
TODO_LIST_END=" — — — — — — — — — — — — — — — — — — — — — — — — — — \n\n" | |
TASKS_DIR=~/.TODO/outstanding/ | |
COMPLETED_DIR=~/.TODO/completed/ | |
function todo { | |
if [ -z "$1" ] | |
then | |
printf "${TODO_LIST_LABEL}" | |
find ${TASKS_DIR} -type f -execdir echo '{}' ';' | sed 's|./||' | nl -s ' [] ' -b a | |
printf "${TODO_LIST_END}" | |
else | |
touch ${TASKS_DIR}"${*}" | |
todo | |
fi | |
} | |
_fin () { | |
IFS=$'\n' tmp=( $(compgen -W "$(ls "${TASKS_DIR}")" — "${COMP_WORDS[$COMP_CWORD]}" )) | |
COMPREPLY=( "${tmp[@]// /\ }" ) | |
IFS=$' ' | |
} | |
function fin { | |
if ! [ -z "$1" ] && [ -a ${TASKS_DIR}"${*}" ] | |
then | |
mv ${TASKS_DIR}"$1" ${COMPLETED_DIR} | |
todo | |
printf " ${GREEN}DONE ${STANDARD}with ${BOLD_AND_UNDERLINED}$1${STANDARD}\n\n" | |
else | |
echo -e "\nusage: fin [existing task to complete]\n" | |
fi | |
} | |
complete -o default -F _fin fin |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment