Advertisement
Guest User

Untitled

a guest
Sep 26th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.43 KB | None | 0 0
  1. #! /bin/bash
  2.  
  3. ### --------
  4. ### BASH Todo v.01
  5. ### A Super Simple Todo CLI
  6. ### Created by: Lazy
  7. ### --------
  8.  
  9. ######################################################################
  10. ####################### INSTALLATION AND USAGE #######################
  11. #
  12. #
  13. # Place todo.sh in your PATH so you can easily run it. Make sure you
  14. # set permissions to write and read.
  15. # You can easily add a task with:
  16. # todo -a "Task goes here"
  17. # You can easily view tasks with:
  18. # todo -l simple (shows a numbered list)
  19. # todo -l full (shows when task is created)
  20. # NOTE: Theres no way to delete tasks yet.
  21.  
  22.  
  23. ## Changelog
  24. # TODOFORMAT needs a way to check the last line and number to add a task # greater than the prev-
  25. # ious line. (MAYBE NOT -.-)
  26.  
  27. # Text color variables
  28. # to be implemented with Priority colors
  29. txtund=$(tput sgr 0 1) # Underline
  30. txtbld=$(tput bold) # Bold
  31. txtred=$(tput setaf 1) # Red
  32. txtgrn=$(tput setaf 2) # Green
  33. txtylw=$(tput setaf 3) # Yellow
  34. txtblu=$(tput setaf 4) # Blue
  35. txtpur=$(tput setaf 5) # Purple
  36. txtcyn=$(tput setaf 6) # Cyan
  37. txtwht=$(tput setaf 7) # White
  38. txtrst=$(tput sgr0) # Text reset
  39.  
  40. #Next on the docket
  41. TODOMARKER() {
  42.  
  43. MARKED=$OPTARG
  44. #TEST=$`awk -F: '{ print $1 }' TODO | tail -n 1`
  45. exit
  46. }
  47.  
  48.  
  49. #Flawless
  50. TODOLIST () {
  51. #awk -F:'{print $1,$4}'
  52. # : delimiter for awk
  53. # | for column
  54. if [[ -a /home/$USER/TODO ]]; then
  55.  
  56. case $OPTARG in
  57. full)
  58. column -t -s "|" ~/TODO | awk -F: 'BEGIN { print " Created On To-do"
  59. print "================ =====================" }
  60. { print $2," ",$3}'
  61. ;;
  62. simple)
  63. column -t -s "|" ~/TODO | awk -F: '{ print "\033[1;31m" $1"." "\033[0m",$3 }'
  64. ;;
  65. esac
  66. else
  67. echo TODO file does not exist. Create a new task first.
  68. fi
  69. }
  70. #Arguments
  71. # -a Add Task
  72. # -r Remove a task
  73. # -d Mark task with a status
  74. # -l List all tasks
  75.  
  76. ## Megaman! Execute!
  77.  
  78. while getopts "a:l:d:" OPTION
  79. do
  80. case $OPTION in
  81. a)
  82. touch /home/$USER/TODO
  83. date=`date +"%Y-%m-%d"`
  84. TEST=`awk -F: '{ print $1 }' ~/TODO | tail -n 1`
  85. declare -i TEST
  86. number=0
  87.  
  88. if [[ $number = $TEST ]] ; then
  89.  
  90. echo $number:|$date:|$OPTARG:|$PRI:| >> /home/$USER/TODO
  91.  
  92. else
  93. let "TEST += 1"
  94. PRI=$3
  95. echo "$TEST:|$date:|$OPTARG:|$PRI:|" >> /home/$USER/TODO
  96. fi
  97. ;;
  98. l)
  99. TODOLIST
  100. ;;
  101. d)
  102. TODOMARK
  103. ;;
  104. esac
  105. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement