├── LICENSE ├── README.md └── reminder.plugin.zsh /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Alexis BRENON 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # oh-my-zsh-reminder 2 | A very very simple OhMyZsh plugin which displays reminders above every prompt 3 | 4 | This small plugin allows your terminal to remind you that you have somethind to do. 5 | Start adding a task : 6 | 7 | $ todo Delete this task 8 | Todo : 9 | - Delete this task 10 | 11 | $ 12 | 13 | You can add an other one : 14 | 15 | $ todo Keep this one 16 | Todo : 17 | - Delete this task 18 | - Keep this one 19 | 20 | $ 21 | 22 | When a task is done, remove it from the list : 23 | 24 | $ task_done Delete 25 | Todo : 26 | - Keep this one 27 | 28 | $ 29 | 30 | When all tasks are done, reminder vanishes : 31 | 32 | $ task_done Keep 33 | 34 | $ 35 | 36 | That's all for the moment. As I said, very very simple. Maybe will be improved later. 37 | 38 | # Installation 39 | 40 | To install, clone the repo into `~/.oh-my-zsh/custom/plugins` (ZSH plugins don't allow dashes, so make sure you clone it into a single-word folder): 41 | ``` bash 42 | git clone https://github.com/AlexisBRENON/oh-my-zsh-reminder ~/.oh-my-zsh/custom/plugins/reminder 43 | ``` 44 | 45 | Then add it to your list of plugins in `~/.zshrc` (e.g `plugins=(reminder common-aliases extract git sudo taskwarrior)`). 46 | -------------------------------------------------------------------------------- /reminder.plugin.zsh: -------------------------------------------------------------------------------- 1 | TODO_SAVE_TASKS_FILE="$HOME/.todo.sav" 2 | TODO_SAVE_COLOR_FILE="$HOME/.todo_color.sav" 3 | 4 | # Allow to use colors 5 | colors 6 | typeset -T -x -g TODO_TASKS todo_tasks 7 | typeset -T -x -g TODO_TASKS_COLORS todo_tasks_colors 8 | typeset -a -x -g todo_colors 9 | typeset -i -x -g todo_color_index 10 | 11 | function load_tasks() { 12 | # Load previous tasks from saved file 13 | if [[ -e "$TODO_SAVE_TASKS_FILE" && 14 | -e "$TODO_SAVE_COLOR_FILE" ]] then 15 | TODO_TASKS="$(cat $TODO_SAVE_TASKS_FILE)" 16 | TODO_TASKS_COLORS="$(head -n1 $TODO_SAVE_COLOR_FILE)" 17 | todo_color_index="$(tail -n1 $TODO_SAVE_COLOR_FILE)" 18 | if [[ -z "$TODO_TASKS" ]] then 19 | todo_tasks[1]=() 20 | todo_tasks_colors[1]=() 21 | fi 22 | else 23 | todo_tasks=() 24 | todo_tasks_colors=() 25 | todo_color_index=1 26 | fi 27 | } 28 | 29 | todo_colors=(red green yellow blue magenta cyan) 30 | autoload -U add-zsh-hook 31 | add-zsh-hook precmd todo_display 32 | 33 | function todo_add_task { 34 | if [[ $# -gt 0 ]] then 35 | # Source: http://stackoverflow.com/a/8997314/1298019 36 | task=$(echo -E "$@" | tr '\n' '\000' | sed 's:\x00\x00.*:\n:g' | tr '\000' '\n') 37 | color="${fg[${todo_colors[${todo_color_index}]}]}" 38 | load_tasks 39 | todo_tasks+="$task" 40 | todo_tasks_colors+="$color" 41 | (( todo_color_index %= ${#todo_colors} )) 42 | (( todo_color_index += 1 )) 43 | todo_save 44 | fi 45 | } 46 | 47 | alias todo=todo_add_task 48 | 49 | function todo_task_done { 50 | pattern="$1" 51 | load_tasks 52 | index=${(M)todo_tasks[(i)${pattern}*]} 53 | todo_tasks[index]=() 54 | todo_tasks_colors[index]=() 55 | todo_save 56 | } 57 | 58 | function _todo_task_done { 59 | load_tasks 60 | if [[ ${#todo_tasks} -gt 0 ]] then 61 | compadd $(echo ${TODO_TASKS} | tr ':' '\n') 62 | fi 63 | } 64 | 65 | compdef _todo_task_done todo_task_done 66 | alias task_done=todo_task_done 67 | 68 | function todo_display { 69 | load_tasks 70 | if [[ ${#todo_tasks} -gt 0 ]] then 71 | printf "$fg_bold[default]Todo :$fg_no_bold[default]\n" 72 | for (( i = 1; i <= ${#todo_tasks}; i++ )); do 73 | printf " - %s%s$fg[default]\n" "${todo_tasks_colors[i]}" "${todo_tasks[i]}" 74 | done 75 | fi 76 | } 77 | 78 | function todo_save { 79 | echo "$TODO_TASKS" > $TODO_SAVE_TASKS_FILE 80 | echo "$TODO_TASKS_COLORS" > $TODO_SAVE_COLOR_FILE 81 | echo "$todo_color_index" >> $TODO_SAVE_COLOR_FILE 82 | } 83 | 84 | --------------------------------------------------------------------------------