add todo.txt-cli as a plugin
Since it is referenced in the default .bash_profile and in aliases and themes, why not make it an official plugin? This creates a 'todo/' directory in /plugins/available, and installs todo.sh and friends there. Tab completion and the 't' alias should work out of the box. Note: it was also necessary to modify .gitignore to ignore the files todo.sh generates in custom/.pull/129/head^2
parent
89263728f2
commit
f5badb3c28
|
|
@ -1,6 +1,6 @@
|
||||||
*/enabled/*
|
*/enabled/*
|
||||||
.DS_Store
|
.DS_Store
|
||||||
custom/*.bash
|
custom/*
|
||||||
!custom/example.bash
|
!custom/example.bash
|
||||||
.rvmrc
|
.rvmrc
|
||||||
aliases/custom.aliases.bash
|
aliases/custom.aliases.bash
|
||||||
|
|
|
||||||
|
|
@ -137,18 +137,6 @@ usage ()
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
t ()
|
|
||||||
{
|
|
||||||
about one thing todo
|
|
||||||
param if not set, display todo item
|
|
||||||
param 1: todo text
|
|
||||||
if [[ "$*" == "" ]] ; then
|
|
||||||
cat ~/.t
|
|
||||||
else
|
|
||||||
echo "$*" > ~/.t
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
command_exists ()
|
command_exists ()
|
||||||
{
|
{
|
||||||
about checks for existence of a command
|
about checks for existence of a command
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
export TODO_DIR=$HOME/.bash_it/custom # store todo items in user's custom dir, ignored by git
|
||||||
|
export TODOTXT_DEFAULT_ACTION=ls # typing 't' by itself will list current todos
|
||||||
|
|
||||||
|
export TODO_SRC_DIR=$HOME/.bash_it/plugins/available/todo
|
||||||
|
|
||||||
|
# respect ENV var set in .bash_profile, default is 't'
|
||||||
|
alias $TODO='$TODO_SRC_DIR/todo.sh -d $TODO_SRC_DIR/todo.cfg'
|
||||||
|
|
||||||
|
export PATH=$PATH:$TODO_SRC_DIR
|
||||||
|
source $TODO_SRC_DIR/todo_completion # bash completion for todo.sh
|
||||||
|
complete -F _todo $TODO # enable completion for 't' alias
|
||||||
|
|
@ -0,0 +1,75 @@
|
||||||
|
# === EDIT FILE LOCATIONS BELOW ===
|
||||||
|
|
||||||
|
# Your todo/done/report.txt locations
|
||||||
|
export TODO_FILE="$TODO_DIR/todo.txt"
|
||||||
|
export DONE_FILE="$TODO_DIR/done.txt"
|
||||||
|
export REPORT_FILE="$TODO_DIR/report.txt"
|
||||||
|
|
||||||
|
# You can customize your actions directory location
|
||||||
|
#export TODO_ACTIONS_DIR="$HOME/.todo.actions.d"
|
||||||
|
|
||||||
|
# == EDIT FILE LOCATIONS ABOVE ===
|
||||||
|
|
||||||
|
# === COLOR MAP ===
|
||||||
|
|
||||||
|
## Text coloring and formatting is done by inserting ANSI escape codes.
|
||||||
|
## If you have re-mapped your color codes, or use the todo.txt
|
||||||
|
## output in another output system (like Conky), you may need to
|
||||||
|
## over-ride by uncommenting and editing these defaults.
|
||||||
|
## If you change any of these here, you also need to uncomment
|
||||||
|
## the defaults in the COLORS section below. Otherwise, todo.txt
|
||||||
|
## will still use the defaults!
|
||||||
|
|
||||||
|
# export BLACK='\\033[0;30m'
|
||||||
|
# export RED='\\033[0;31m'
|
||||||
|
# export GREEN='\\033[0;32m'
|
||||||
|
# export BROWN='\\033[0;33m'
|
||||||
|
# export BLUE='\\033[0;34m'
|
||||||
|
# export PURPLE='\\033[0;35m'
|
||||||
|
# export CYAN='\\033[0;36m'
|
||||||
|
# export LIGHT_GREY='\\033[0;37m'
|
||||||
|
# export DARK_GREY='\\033[1;30m'
|
||||||
|
# export LIGHT_RED='\\033[1;31m'
|
||||||
|
# export LIGHT_GREEN='\\033[1;32m'
|
||||||
|
# export YELLOW='\\033[1;33m'
|
||||||
|
# export LIGHT_BLUE='\\033[1;34m'
|
||||||
|
# export LIGHT_PURPLE='\\033[1;35m'
|
||||||
|
# export LIGHT_CYAN='\\033[1;36m'
|
||||||
|
# export WHITE='\\033[1;37m'
|
||||||
|
# export DEFAULT='\\033[0m'
|
||||||
|
|
||||||
|
# === COLORS ===
|
||||||
|
|
||||||
|
## Uncomment and edit to override these defaults.
|
||||||
|
## Reference the constants from the color map above,
|
||||||
|
## or use $NONE to disable highlighting.
|
||||||
|
#
|
||||||
|
# Priorities can be any upper-case letter.
|
||||||
|
# A,B,C are highlighted; you can add coloring for more.
|
||||||
|
#
|
||||||
|
# export PRI_A=$YELLOW # color for A priority
|
||||||
|
# export PRI_B=$GREEN # color for B priority
|
||||||
|
# export PRI_C=$LIGHT_BLUE # color for C priority
|
||||||
|
# export PRI_D=... # define your own
|
||||||
|
# export PRI_X=$WHITE # color unless explicitly defined
|
||||||
|
|
||||||
|
# There is highlighting for tasks that have been done,
|
||||||
|
# but haven't been archived yet.
|
||||||
|
#
|
||||||
|
# export COLOR_DONE=$LIGHT_GREY
|
||||||
|
|
||||||
|
# === BEHAVIOR ===
|
||||||
|
|
||||||
|
## customize list output
|
||||||
|
#
|
||||||
|
# TODOTXT_SORT_COMMAND will filter after line numbers are
|
||||||
|
# inserted, but before colorization, and before hiding of
|
||||||
|
# priority, context, and project.
|
||||||
|
#
|
||||||
|
# export TODOTXT_SORT_COMMAND='env LC_COLLATE=C sort -f -k2'
|
||||||
|
|
||||||
|
# TODOTXT_FINAL_FILTER will filter list output after colorization,
|
||||||
|
# priority hiding, context hiding, and project hiding. That is,
|
||||||
|
# just before the list output is displayed.
|
||||||
|
#
|
||||||
|
# export TODOTXT_FINAL_FILTER='cat'
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,107 @@
|
||||||
|
#!/bin/bash source-this-script
|
||||||
|
[ "$BASH_VERSION" ] || return
|
||||||
|
|
||||||
|
_todo()
|
||||||
|
{
|
||||||
|
local cur prev opts
|
||||||
|
COMPREPLY=()
|
||||||
|
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||||
|
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||||
|
|
||||||
|
local -r OPTS="-@ -@@ -+ -++ -d -f -h -p -P -PP -a -n -t -v -vv -V -x"
|
||||||
|
local -r COMMANDS="\
|
||||||
|
add a addto addm append app archive command del \
|
||||||
|
rm depri dp do help list ls listaddons listall lsa listcon \
|
||||||
|
lsc listfile lf listpri lsp listproj lsprj move \
|
||||||
|
mv prepend prep pri p replace report shorthelp"
|
||||||
|
|
||||||
|
local _todo_sh=${_todo_sh:-todo.sh}
|
||||||
|
local completions
|
||||||
|
if [ $COMP_CWORD -eq 1 ]; then
|
||||||
|
completions="$COMMANDS $(eval TODOTXT_VERBOSE=0 $_todo_sh command listaddons) $OPTS"
|
||||||
|
elif [[ $COMP_CWORD -gt 2 && ( \
|
||||||
|
"${COMP_WORDS[COMP_CWORD-2]}" =~ ^(move|mv)$ || \
|
||||||
|
"${COMP_WORDS[COMP_CWORD-3]}" =~ ^(move|mv)$ ) ]]; then
|
||||||
|
# "move ITEM# DEST [SRC]" has file arguments on positions 2 and 3.
|
||||||
|
completions=$(eval TODOTXT_VERBOSE=0 $_todo_sh command listfile)
|
||||||
|
else
|
||||||
|
case "$prev" in
|
||||||
|
command)
|
||||||
|
completions=$COMMANDS;;
|
||||||
|
addto|listfile|lf)
|
||||||
|
completions=$(eval TODOTXT_VERBOSE=0 $_todo_sh command listfile);;
|
||||||
|
-*) completions="$COMMANDS $(eval TODOTXT_VERBOSE=0 $_todo_sh command listaddons) $OPTS";;
|
||||||
|
*) case "$cur" in
|
||||||
|
+*) completions=$(eval TODOTXT_VERBOSE=0 $_todo_sh command listproj)
|
||||||
|
COMPREPLY=( $( compgen -W "$completions" -- $cur ))
|
||||||
|
[ ${#COMPREPLY[@]} -gt 0 ] && return 0
|
||||||
|
# Fall back to projects extracted from done tasks.
|
||||||
|
completions=$(eval 'TODOTXT_VERBOSE=0 TODOTXT_SOURCEVAR=\$DONE_FILE' $_todo_sh command listproj)
|
||||||
|
;;
|
||||||
|
@*) completions=$(eval TODOTXT_VERBOSE=0 $_todo_sh command listcon)
|
||||||
|
COMPREPLY=( $( compgen -W "$completions" -- $cur ))
|
||||||
|
[ ${#COMPREPLY[@]} -gt 0 ] && return 0
|
||||||
|
# Fall back to contexts extracted from done tasks.
|
||||||
|
completions=$(eval 'TODOTXT_VERBOSE=0 TODOTXT_SOURCEVAR=\$DONE_FILE' $_todo_sh command listcon)
|
||||||
|
;;
|
||||||
|
*) if [[ "$cur" =~ ^[0-9]+$ ]]; then
|
||||||
|
# Remove the (padded) task number; we prepend the
|
||||||
|
# user-provided $cur instead.
|
||||||
|
# Remove the timestamp prepended by the -t option,
|
||||||
|
# and the done date (for done tasks); there's no
|
||||||
|
# todo.txt option for that yet.
|
||||||
|
# But keep priority and "x"; they're short and may
|
||||||
|
# provide useful context.
|
||||||
|
# Remove any trailing whitespace; the Bash
|
||||||
|
# completion inserts a trailing space itself.
|
||||||
|
# Finally, limit the output to a single line just as
|
||||||
|
# a safety check of the ls action output.
|
||||||
|
local todo=$( \
|
||||||
|
eval TODOTXT_VERBOSE=0 $_todo_sh '-@ -+ -p -x command ls "^ *${cur} "' | \
|
||||||
|
sed -e 's/^ *[0-9]\{1,\} //' -e 's/\((.) \)[0-9]\{2,4\}-[0-9]\{2\}-[0-9]\{2\} /\1/' \
|
||||||
|
-e 's/\([xX] \)\([0-9]\{2,4\}-[0-9]\{2\}-[0-9]\{2\} \)\{1,2\}/\1/' \
|
||||||
|
-e 's/[[:space:]]*$//' \
|
||||||
|
-e '1q' \
|
||||||
|
)
|
||||||
|
# Append task text as a shell comment. This
|
||||||
|
# completion can be a safety check before a
|
||||||
|
# destructive todo.txt operation.
|
||||||
|
[ "$todo" ] && COMPREPLY[0]="$cur # $todo"
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
COMPREPLY=( $( compgen -W "$completions" -- $cur ))
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
complete -F _todo todo.sh
|
||||||
|
|
||||||
|
# If you define an alias (e.g. "t") to todo.sh, you need to explicitly enable
|
||||||
|
# completion for it, too:
|
||||||
|
#complete -F _todo t
|
||||||
|
|
||||||
|
# If you have renamed the todo.sh executable, or if it is not accessible through
|
||||||
|
# PATH, you need to add and use a wrapper completion function, like this:
|
||||||
|
#_todoElsewhere()
|
||||||
|
#{
|
||||||
|
# local _todo_sh='/path/to/todo2.sh'
|
||||||
|
# _todo "$@"
|
||||||
|
#}
|
||||||
|
#complete -F _todoElsewhere /path/to/todo2.sh
|
||||||
|
|
||||||
|
# If you use aliases to use different configuration(s), you need to add and use
|
||||||
|
# a wrapper completion function for each configuration if you want to complete
|
||||||
|
# fron the actual configured task locations:
|
||||||
|
#alias todo2='todo.sh -d "$HOME/todo2.cfg"'
|
||||||
|
#_todo2()
|
||||||
|
#{
|
||||||
|
# local _todo_sh='todo.sh -d "$HOME/todo2.cfg"'
|
||||||
|
# _todo "$@"
|
||||||
|
#}
|
||||||
|
#complete -F _todo2 todo2
|
||||||
Loading…
Reference in New Issue