Advertisement
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)
- # NOTE: Theres no way to delete tasks yet.
- ## Changelog
- # TODOFORMAT needs a way to check the last line and number to add a task # greater than the prev-
- # ious line. (MAYBE NOT -.-)
- # 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
- #Next on the docket
- TODOMARKER() {
- MARKED=$OPTARG
- #TEST=$`awk -F: '{ print $1 }' TODO | tail -n 1`
- exit
- }
- #Flawless
- 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
- }
- #Arguments
- # -a Add Task
- # -r Remove a task
- # -d Mark task with a status
- # -l List all tasks
- ## Megaman! Execute!
- while getopts "a:l:d:" OPTION
- do
- case $OPTION in
- 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
- ;;
- d)
- TODOMARK
- ;;
- esac
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement