a simple terminal todo list that could be improved
mkdir -p ~/todo/do ~/todo/done
paste the code into your .bashrc
tasks are stored as file names ex. # todo taxes , # todo mow grass
but multi word tasks need to be enclosed in quotes to be removed from the todo list
ex. # todo 'mow grass'
hmm ?
Code: Select all
# mkdir -p ~/todo/do ~/todo/done
# paste this code to your .bashrc
# https://sambrin.medium.com/fin-command-line-todo-list-made-with-30a2346de068
#STANDARD="\e[0m"
TODO_LIST_LABEL="\n----------Todo List-----------\n"
TODO_LIST_END="\n------------------------------\n"
TASKS_DIR=~/todo/do/
COMPLETED_DIR=~/todo/done/
function todo {
if [ -z "$1" ]
then
printf "${TODO_LIST_LABEL}"
find ${TASKS_DIR} -not -path '*/\.*' -type f -execdir echo '{}' ';' | nl -s ' ' -b n
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" ]] && [ -e ${TASKS_DIR}"${*}" ]
then
mv ${TASKS_DIR}"$1" ${COMPLETED_DIR}
todo
printf " $1 removed from list \n\n"
else
echo -e "\nusage: fin [existing task to complete]\n"
fi
}
complete -o default -F _fin fin