respect TIMEWARRIORDB environment variable (#471)

Signed-off-by: David Ward <dward@redhat.com>
This commit is contained in:
David Ward 2020-02-05 15:00:56 -05:00 committed by GitHub
parent be7e7b3b15
commit a06bbdc196
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 6 deletions

View File

@ -4362,8 +4362,9 @@ function instant_prompt_direnv() {
function prompt_timewarrior() { function prompt_timewarrior() {
local -a stat local -a stat
local timewarriordb=${TIMEWARRIORDB:-~/.timewarrior}
if [[ -n $_p9k_timewarrior_file_name ]]; then if [[ -n $_p9k_timewarrior_file_name ]]; then
zstat -A stat +mtime -- ~/.timewarrior/data $_p9k_timewarrior_file_name 2>/dev/null || stat=() zstat -A stat +mtime -- ${timewarriordb}/data $_p9k_timewarrior_file_name 2>/dev/null || stat=()
if [[ $stat[1] == $_p9k_timewarrior_dir_mtime && $stat[2] == $_p9k_timewarrior_file_mtime ]]; then if [[ $stat[1] == $_p9k_timewarrior_dir_mtime && $stat[2] == $_p9k_timewarrior_file_mtime ]]; then
if (( $+_p9k_timewarrior_tags )); then if (( $+_p9k_timewarrior_tags )); then
_p9k_prompt_segment $0 grey 255 TIMEWARRIOR_ICON 0 '' "${_p9k_timewarrior_tags//\%/%%}" _p9k_prompt_segment $0 grey 255 TIMEWARRIOR_ICON 0 '' "${_p9k_timewarrior_tags//\%/%%}"
@ -4371,7 +4372,7 @@ function prompt_timewarrior() {
return return
fi fi
fi fi
if [[ ! -d ~/.timewarrior/data ]]; then if [[ ! -d ${timewarriordb}/data ]]; then
_p9k_timewarrior_dir_mtime=0 _p9k_timewarrior_dir_mtime=0
_p9k_timewarrior_file_mtime=0 _p9k_timewarrior_file_mtime=0
_p9k_timewarrior_file_name= _p9k_timewarrior_file_name=
@ -4379,12 +4380,12 @@ function prompt_timewarrior() {
return return
fi fi
if [[ $stat[1] != $_p9k_timewarrior_dir_mtime ]]; then if [[ $stat[1] != $_p9k_timewarrior_dir_mtime ]]; then
local -a files=(~/.timewarrior/data/<->-<->.data(.N)) local -a files=(${timewarriordb}/data/<->-<->.data(.N))
if (( ! $#files )); then if (( ! $#files )); then
if (( $#stat )) || zstat -A stat +mtime -- ~/.timewarrior/data 2>/dev/null; then if (( $#stat )) || zstat -A stat +mtime -- ${timewarriordb}/data 2>/dev/null; then
_p9k_timewarrior_dir_mtime=$stat[1] _p9k_timewarrior_dir_mtime=$stat[1]
_p9k_timewarrior_file_mtime=$stat[1] _p9k_timewarrior_file_mtime=$stat[1]
_p9k_timewarrior_file_name=~/.timewarrior/data _p9k_timewarrior_file_name=${timewarriordb}/data
else else
_p9k_timewarrior_dir_mtime=0 _p9k_timewarrior_dir_mtime=0
_p9k_timewarrior_file_mtime=0 _p9k_timewarrior_file_mtime=0
@ -4395,7 +4396,7 @@ function prompt_timewarrior() {
fi fi
_p9k_timewarrior_file_name=${${(AO)files}[1]} _p9k_timewarrior_file_name=${${(AO)files}[1]}
fi fi
if ! zstat -A stat +mtime -- ~/.timewarrior/data $_p9k_timewarrior_file_name 2>/dev/null; then if ! zstat -A stat +mtime -- ${timewarriordb}/data $_p9k_timewarrior_file_name 2>/dev/null; then
_p9k_timewarrior_dir_mtime=0 _p9k_timewarrior_dir_mtime=0
_p9k_timewarrior_file_mtime=0 _p9k_timewarrior_file_mtime=0
_p9k_timewarrior_file_name= _p9k_timewarrior_file_name=