[remove] todo app not used anymore

This commit is contained in:
2023-11-17 20:18:14 +08:00
parent dbc0c638fd
commit 52dccb1787
5 changed files with 0 additions and 0 deletions

154
old/todo/todo.cfg Normal file
View File

@ -0,0 +1,154 @@
# === EDIT FILE LOCATIONS BELOW ===
# Your todo.txt directory (this should be an absolute path)
export TODO_DIR="/opt/logs/TODO"
# export TODO_DIR=$(dirname "$0")
# 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!
#======> normal <========
export BLACK='\\033[0;30m'
export RED='\\033[0;31m'
export GREEN='\\033[0;32m'
export YELLOW='\\033[0;33m'
export BLUE='\\033[0;34m'
export PURPLE='\\033[0;35m'
export CYAN='\\033[0;36m'
export GREY='\\033[0;37m'
#======> bold <========
export BOLD_BLACK='\\033[1;30m'
export BOLD_RED='\\033[1;31m'
export BOLD_GREEN='\\033[1;32m'
export BOLD_YELLOW='\\033[1;33m'
export BOLD_BLUE='\\033[1;34m'
export BOLD_PURPLE='\\033[1;35m'
export BOLD_CYAN='\\033[1;36m'
export BOLD_GREY='\\033[1;37m'
#======> italic <========
export ITALIC_BLACK='\\033[3;30m'
export ITALIC_RED='\\033[3;31m'
export ITALIC_GREEN='\\033[3;32m'
export ITALIC_YELLOW='\\033[3;33m'
export ITALIC_BLUE='\\033[3;34m'
export ITALIC_PURPLE='\\033[3;35m'
export ITALIC_CYAN='\\033[3;36m'
export ITALIC_GREY='\\033[3;37m'
#======> underline <========
export UNDERLINE_BLACK='\\033[4;30m'
export UNDERLINE_RED='\\033[3;41m'
export UNDERLINE_GREEN='\\033[4;32m'
export UNDERLINE_YELLOW='\\033[4;33m'
export UNDERLINE_BLUE='\\033[4;34m'
export UNDERLINE_PURPLE='\\033[4;35m'
export UNDERLINE_CYAN='\\033[4;36m'
export UNDERLINE_GREY='\\033[4;37m'
#======> bold & italic <========
export BOLD_ITALIC_BLACK='\\033[1;3;30m'
export BOLD_ITALIC_RED='\\033[1;3;31m'
export BOLD_ITALIC_GREEN='\\033[1;3;32m'
export BOLD_ITALIC_YELLOW='\\033[1;3;33m'
export BOLD_ITALIC_BLUE='\\033[1;3;34m'
export BOLD_ITALIC_PURPLE='\\033[1;3;35m'
export BOLD_ITALIC_CYAN='\\033[1;3;36m'
export BOLD_ITALIC_GREY='\\033[1;3;37m'
#======> bold & underline <========
export BOLD_UNDERLINE_BLACK='\\033[1;4;30m'
export BOLD_UNDERLINE_RED='\\033[1;4;31m'
export BOLD_UNDERLINE_GREEN='\\033[1;4;32m'
export BOLD_UNDERLINE_YELLOW='\\033[1;4;33m'
export BOLD_UNDERLINE_BLUE='\\033[1;4;34m'
export BOLD_UNDERLINE_PURPLE='\\033[1;4;35m'
export BOLD_UNDERLINE_CYAN='\\033[1;4;36m'
export BOLD_UNDERLINE_GREY='\\033[1;4;37m'
#======> italic & underline <========
export ITALIC_UNDERLINE_BLACK='\\033[3;4;30m'
export ITALIC_UNDERLINE_RED='\\033[3;4;31m'
export ITALIC_UNDERLINE_GREEN='\\033[3;4;32m'
export ITALIC_UNDERLINE_YELLOW='\\033[3;4;33m'
export ITALIC_UNDERLINE_BLUE='\\033[3;4;34m'
export ITALIC_UNDERLINE_PURPLE='\\033[3;4;35m'
export ITALIC_UNDERLINE_CYAN='\\033[3;4;36m'
export ITALIC_UNDERLINE_GREY='\\033[3;4;37m'
#======> bold & italic & underline <========
export BOLD_ITALIC_UNDERLINE_BLACK='\\033[1;3;4;30m'
export BOLD_ITALIC_UNDERLINE_RED='\\033[1;3;4;31m'
export BOLD_ITALIC_UNDERLINE_GREEN='\\033[1;3;4;32m'
export BOLD_ITALIC_UNDERLINE_YELLOW='\\033[1;3;4;33m'
export BOLD_ITALIC_UNDERLINE_BLUE='\\033[1;3;4;34m'
export BOLD_ITALIC_UNDERLINE_PURPLE='\\033[1;3;4;35m'
export BOLD_ITALIC_UNDERLINE_CYAN='\\033[1;3;4;36m'
export BOLD_ITALIC_UNDERLINE_GREY='\\033[1;3;4;37m'
#======> REAL PRI COLOR <========
PRI_A_COLOR='\\033[1;4;31;47m'
PRI_B_COLOR='\\033[1;4;31;42m'
PRI_C_COLOR='\\033[1;4;31;43m'
PRI_D_COLOR='\\033[1;4;31;44m'
PRI_E_COLOR='\\033[1;4;31;46m'
#======> restore normal <========
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=$PRI_A_COLOR # color for A priority
export PRI_B=$PRI_B_COLOR # color for B priority
export PRI_C=$PRI_C_COLOR # color for C priority
export PRI_D=$PRI_D_COLOR # color for D priority
export PRI_E=$PRI_E_COLOR # color for E priority
# There is highlighting for tasks that have been done,
# but haven't been archived yet.
#
export COLOR_DONE=$BOLD_ITALIC_UNDERLINE_GREY
# There is highlighting for projects, contexts, dates, and item numbers.
export COLOR_PROJECT=$ITALIC_UNDERLINE_PURPLE
export COLOR_CONTEXT=$ITALIC_UNDERLINE_GREEN
export COLOR_DATE=$BOLD_BLUE
export COLOR_NUMBER=$BOLD_PURPLE
# There is highlighting for metadata key:value pairs e.g.
# DUE:2006-08-01 or note:MYNOTE
export COLOR_META=$BOLD_CYAN
# === 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'

1531
old/todo/todo.sh Executable file

File diff suppressed because it is too large Load Diff

120
old/todo/todo_completion Executable file
View File

@ -0,0 +1,120 @@
#!/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 -r MOVE_COMMAND_PATTERN='move|mv'
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 2>/dev/null) $OPTS"
elif [[ $COMP_CWORD -gt 2 && ( \
"${COMP_WORDS[COMP_CWORD-2]}" =~ ^($MOVE_COMMAND_PATTERN${_todo_file2_actions:+|${_todo_file2_actions}})$ || \
"${COMP_WORDS[COMP_CWORD-3]}" =~ ^($MOVE_COMMAND_PATTERN${_todo_file3_actions:+|${_todo_file3_actions}})$ ) ]]; then
# "move ITEM# DEST [SRC]" has file arguments on positions 2 and 3.
completions=$(eval TODOTXT_VERBOSE=0 $_todo_sh command listfile 2>/dev/null)
else
case "$prev" in
command)
completions=$COMMANDS;;
help)
completions="$COMMANDS $(eval TODOTXT_VERBOSE=0 $_todo_sh command listaddons 2>/dev/null)";;
-*) completions="$COMMANDS $(eval TODOTXT_VERBOSE=0 $_todo_sh command listaddons 2>/dev/null) $OPTS";;
*) if [[ "$prev" =~ ^(addto|listfile|lf${_todo_file1_actions:+|${_todo_file1_actions}})$ ]]; then
completions=$(eval TODOTXT_VERBOSE=0 $_todo_sh command listfile 2>/dev/null)
else
case "$cur" in
+*) completions=$(eval TODOTXT_VERBOSE=0 $_todo_sh command listproj 2>/dev/null)
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 2>/dev/null)
;;
@*) completions=$(eval TODOTXT_VERBOSE=0 $_todo_sh command listcon 2>/dev/null)
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 2>/dev/null)
;;
*) if [[ "$cur" =~ ^[0-9]+$ ]]; then
declare -a sedTransformations=(
# Remove the (padded) task number; we prepend the
# user-provided $cur instead.
-e 's/^ *[0-9]\{1,\} //'
# Remove the timestamp prepended by the -t option,
# but keep any priority (as it's short and may
# provide useful context).
-e 's/^\((.) \)\{0,1\}[0-9]\{2,4\}-[0-9]\{2\}-[0-9]\{2\} /\1/'
# Remove the done date and (if there) the timestamp.
# Keep the "x" (as it's short and may provide useful
# context)
-e 's/^\([xX] \)\([0-9]\{2,4\}-[0-9]\{2\}-[0-9]\{2\} \)\{1,2\}/\1/'
# Remove any trailing whitespace; the Bash
# completion inserts a trailing space itself.
-e 's/[[:space:]]*$//'
# Finally, limit the output to a single line just as
# a safety check of the ls action output.
-e '1q'
)
local todo=$( \
eval TODOTXT_VERBOSE=0 $_todo_sh '-@ -+ -p -x command ls "^ *${cur} "' 2>/dev/null | \
sed "${sedTransformations[@]}" \
)
# 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
fi
;;
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
# It is recommended to put this line next to your alias definition in your
# ~/.bashrc (or wherever else you're defining your alias). If you simply
# uncomment it here, you will need to redo this on every todo.txt update!
# 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
# from 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

136
old/todo/todo_format.py Normal file
View File

@ -0,0 +1,136 @@
import os
import time
import re
def utf8_length(text):
if text is None:
return 0
len_text = len(text)
len_text_utf8 = len(text.encode('utf-8'))
# utf-8一个汉字占3个字符减去原计数就是多出来的2/3再除以2就是增量。再加回去即可
size = int((len_text_utf8 - len_text) / 2 + len_text)
return size
def tidy_done():
with open('/opt/logs/TODO/done.txt', 'r') as donetxt, open('/tmp/tmp_done.txt', 'w') as tmpdone:
lines = donetxt.readlines()
for line in lines:
tmpdone.write(line.strip() + '\n')
os.system('mv /tmp/tmp_done.txt /opt/logs/TODO/done.txt')
def format_col_1(item):
global number_of_days
global item_no
global auto_weekend
end_time_date = item.strip()[-10:]
try:
end_time_stamp = time.strptime(end_time_date, "%Y-%m-%d")
except Exception as Err:
print('Error Encounted: ', end='')
print(str(Err))
print(f"Please modify /opt/logs/TODO/todo.txt @ line {item_no} manually, and then run it again.\n")
os._exit(1)
end_time_stamp = time.mktime(end_time_stamp)
now_time_stamp = int(time.time())
number_of_days = round((end_time_stamp - now_time_stamp) / 3600 / 24 + 0.75, 2)
# print('number_of_days-1:', number_of_days)
if auto_weekend and number_of_days < 0:
end_time_stamp += 604800
end_time_date = time.strftime('%Y-%m-%d', time.localtime(end_time_stamp))
item = item.strip()[:-10] + end_time_date
number_of_days += 7
item_format = re.sub(' +', ' ', item.strip())
done.write(item_format)
for i in range(16 - len(item_format)):
done.write(' ')
done.write('|')
def format_col_2(item):
done.write(' ')
done.write(item.strip())
for i in range(12 - 1 - len(item.strip())):
done.write(' ')
done.write('|')
def format_col_3(item):
global number_of_days
# print('number_of_days-3:', number_of_days)
item = 'T:' + str(number_of_days)
done.write(' ')
done.write(item.strip())
for i in range(10 - 1 - len(item.strip())):
done.write(' ')
done.write('|')
def format_col_4(item):
done.write(' ')
try:
with open('/tmp/col.log', 'r') as obj_col:
width = int(obj_col.readline().strip())
except:
width = 125
item_format = re.sub(' +', ' ', item.strip())
len_of_task = utf8_length(item_format)
# get the width of current terminal
left_white = width - 11 - 12 - 10 - 5 - len_of_task - 8
done.write(item_format + ' ' * left_white + '\n')
if __name__ == "__main__":
number_of_days = 0
item_no = 1
# 0 signifies that task without priority, and 1 vice versa
with open('/opt/logs/TODO/todo.txt', 'r') as todo, open('/tmp/tmp.txt', 'w') as done:
for line in todo.readlines():
col = 1
auto_weekend = 0
if line.strip() == '':
continue
elif 'Happy weekend~' in line:
auto_weekend = 1
else:
pass
for item in line.strip().split('|'):
if col == 1:
format_col_1(item)
elif col == 2:
format_col_2(item)
elif col == 3:
format_col_3(item)
elif col == 4:
format_col_4(item)
else:
break
col += 1
item_no += 1
os.system('mv /tmp/tmp.txt /opt/logs/TODO/todo.txt')
tidy_done()

15
old/todo/watch_todo.sh Normal file
View File

@ -0,0 +1,15 @@
#!/bin/bash
tput cols > /tmp/col.log
python3 /opt/scripts/todo/todo_format.py
result=$?
rm -rf /tmp/col.log
exit $result
# while :; do
# echo $COLUMNS > /tmp/col.log
# python3 /opt/scripts/todo/todo_format.py
# sleep 1
# done