Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /bin/bash
- ### --------
- ### BASH Todo v.01
- ### A Super Simple Todo CLI
- ### Created by: Lazy
- ### --------
- ######################################################################
- ####################### INSTALLATION AND USAGE #######################
- #
- #
- # Place todo.sh in your PATH so you can easily run it. Make sure you
- # set permissions to write and read.
- # You can easily add a task with:
- # todo -a "Task goes here"
- # You can easily view tasks with:
- # todo -l simple (shows a numbered list)
- # todo -l full (shows when task is created)
- #
- ## Changelog
- # -TODOFORMAT removed. Task numberer finished. (For some reason the function
- # doesn't manipulate TODO file (WHY?) )
- # Text color variables
- # to be implemented with Priority colors
- txtund=$(tput sgr 0 1) # Underline
- txtbld=$(tput bold) # Bold
- txtred=$(tput setaf 1) # Red
- txtgrn=$(tput setaf 2) # Green
- txtylw=$(tput setaf 3) # Yellow
- txtblu=$(tput setaf 4) # Blue
- txtpur=$(tput setaf 5) # Purple
- txtcyn=$(tput setaf 6) # Cyan
- txtwht=$(tput setaf 7) # White
- txtrst=$(tput sgr0) # Text reset
- TODORM () {
- TASKNUM=`awk -F: '{ print $1 }' ~/TODO | grep -w $OPTARG`
- if [[ "$OPTARG" = "$TASKNUM" ]]; then
- grep -wv "^[${OPTARG}]" TODO > NEWTODO
- cp NEWTODO TODO
- else
- echo "Error: Task $OPTARG does not exist"
- fi
- }
- TODOLIST () {
- #awk -F:'{print $1,$4}'
- # : delimiter for awk
- # | for column
- if [[ -a /home/$USER/TODO ]]; then
- case $OPTARG in
- full)
- column -t -s "|" ~/TODO | awk -F: 'BEGIN { print " Created On To-do"
- print "================ =====================" }
- { print $2," ",$3}'
- ;;
- simple)
- column -t -s "|" ~/TODO | awk -F: '{ print "\033[1;31m" $1"." "\033[0m",$3 }'
- ;;
- esac
- else
- echo TODO file does not exist. Create a new task first.
- fi
- }
- ### END DEFINING FUNCTIONS ####
- while getopts "a:l:m:h" OPTION
- do
- case $OPTION in
- h)
- echo "OPTIONS:"
- echo " todo -a "[\"Task goes here\"]" "
- echo " todo -l [OPTION]"
- echo " simple -- shows a numbered list "
- echo " full -- shows a full list with creation date"
- echo " todo -m "[Task number]" "
- echo " To clear out tasklist simply delete the TODO file in your /home/$USER/"
- ;;
- a)
- touch /home/$USER/TODO
- date=`date +"%Y-%m-%d"`
- TEST=`awk -F: '{ print $1 }' ~/TODO | tail -n 1`
- declare -i TEST
- number=0
- if [[ $number = $TEST ]] ; then
- echo "$number:|$date:|$OPTARG:|$PRI:|" >> /home/$USER/TODO
- else
- let "TEST += 1"
- PRI=$3
- echo "$TEST:|$date:|$OPTARG:|$PRI:|" >> /home/$USER/TODO
- fi
- ;;
- l)
- TODOLIST
- ;;
- m)
- TODORM
- exit 0 ;;
- esac
- done
Add Comment
Please, Sign In to add comment