1
0
Fork 0
mirror of https://github.com/romkatv/powerlevel10k.git synced 2024-11-22 12:20:07 +00:00

make todo segment work if todo-cli is installed from apt; see #785

This commit is contained in:
Roman Perepelitsa 2020-06-02 10:30:35 +02:00
parent 537c2b04e1
commit 2b1d0e599c

View file

@ -3294,10 +3294,9 @@ instant_prompt_date() {
# todo.sh: shows the number of tasks in your todo.sh file # todo.sh: shows the number of tasks in your todo.sh file
prompt_todo() { prompt_todo() {
unset P9K_TODO_TOTAL_TASK_COUNT P9K_TODO_FILTERED_TASK_COUNT unset P9K_TODO_TOTAL_TASK_COUNT P9K_TODO_FILTERED_TASK_COUNT
[[ -r $_p9k__todo_file ]] || return [[ -r $_p9k__todo_file && -x $_p9k__todo_command ]] || return
local todo=$commands[todo.sh]
if ! _p9k_cache_stat_get $0 $_p9k__todo_file; then if ! _p9k_cache_stat_get $0 $_p9k__todo_file; then
local count="$($todo -p ls | tail -1)" local count="$($_p9k__todo_command -p ls | command tail -1)"
if [[ $count == (#b)'TODO: '([[:digit:]]##)' of '([[:digit:]]##)' '* ]]; then if [[ $count == (#b)'TODO: '([[:digit:]]##)' of '([[:digit:]]##)' '* ]]; then
_p9k_cache_stat_set 1 $match[1] $match[2] _p9k_cache_stat_set 1 $match[1] $match[2]
else else
@ -3319,7 +3318,7 @@ prompt_todo() {
} }
_p9k_prompt_todo_init() { _p9k_prompt_todo_init() {
typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='$commands[todo.sh]' typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='$_p9k__todo_file'
} }
################################################################ ################################################################
@ -6684,6 +6683,7 @@ _p9k_init_vars() {
typeset -ga _p9k_left_join typeset -ga _p9k_left_join
typeset -ga _p9k_right_join typeset -ga _p9k_right_join
typeset -g _p9k__public_ip typeset -g _p9k__public_ip
typeset -g _p9k__todo_command
typeset -g _p9k__todo_file typeset -g _p9k__todo_file
typeset -g _p9k__git_dir typeset -g _p9k__git_dir
# git workdir => 1 if gitstatus is slow on it, 0 if it's fast. # git workdir => 1 if gitstatus is slow on it, 0 if it's fast.
@ -7717,7 +7717,7 @@ _p9k_must_init() {
[[ $sig == $_p9k__param_sig ]] && return 1 [[ $sig == $_p9k__param_sig ]] && return 1
_p9k_deinit _p9k_deinit
fi fi
_p9k__param_pat=$'v92\1'${ZSH_VERSION}$'\1'${ZSH_PATCHLEVEL}$'\1' _p9k__param_pat=$'v93\1'${ZSH_VERSION}$'\1'${ZSH_PATCHLEVEL}$'\1'
_p9k__param_pat+=$'${#parameters[(I)POWERLEVEL9K_*]}\1${(%):-%n%#}\1$GITSTATUS_LOG_LEVEL\1' _p9k__param_pat+=$'${#parameters[(I)POWERLEVEL9K_*]}\1${(%):-%n%#}\1$GITSTATUS_LOG_LEVEL\1'
_p9k__param_pat+=$'$GITSTATUS_ENABLE_LOGGING\1$GITSTATUS_DAEMON\1$GITSTATUS_NUM_THREADS\1' _p9k__param_pat+=$'$GITSTATUS_ENABLE_LOGGING\1$GITSTATUS_DAEMON\1$GITSTATUS_NUM_THREADS\1'
_p9k__param_pat+=$'$GITSTATUS_CACHE_DIR\1$GITSTATUS_AUTO_INSTALL\1${ZLE_RPROMPT_INDENT:-1}\1' _p9k__param_pat+=$'$GITSTATUS_CACHE_DIR\1$GITSTATUS_AUTO_INSTALL\1${ZLE_RPROMPT_INDENT:-1}\1'
@ -8091,19 +8091,22 @@ _p9k_init() {
fi fi
if _p9k_segment_in_use todo; then if _p9k_segment_in_use todo; then
local todo=$commands[todo.sh] if [[ -n ${_p9k__todo_command::=${commands[todo.sh]}} ]]; then
if [[ -n $todo ]]; then local todo_global=/etc/todo/config
local bash=${commands[bash]:-:} elif [[ -n ${_p9k__todo_command::=${commands[todo-txt]}} ]]; then
_p9k__todo_file="$(exec -a $todo $bash 2>/dev/null -c " local todo_global=/etc/todo-txt/config
fi
if [[ -n $_p9k__todo_command ]]; then
_p9k__todo_file="$(exec -a $_p9k__todo_command ${commands[bash]:-:} 3>&1 &>/dev/null -c "
[ -e \"\$TODOTXT_CFG_FILE\" ] || TODOTXT_CFG_FILE=\$HOME/.todo/config [ -e \"\$TODOTXT_CFG_FILE\" ] || TODOTXT_CFG_FILE=\$HOME/.todo/config
[ -e \"\$TODOTXT_CFG_FILE\" ] || TODOTXT_CFG_FILE=\$HOME/todo.cfg [ -e \"\$TODOTXT_CFG_FILE\" ] || TODOTXT_CFG_FILE=\$HOME/todo.cfg
[ -e \"\$TODOTXT_CFG_FILE\" ] || TODOTXT_CFG_FILE=\$HOME/.todo.cfg [ -e \"\$TODOTXT_CFG_FILE\" ] || TODOTXT_CFG_FILE=\$HOME/.todo.cfg
[ -e \"\$TODOTXT_CFG_FILE\" ] || TODOTXT_CFG_FILE=\${XDG_CONFIG_HOME:-\$HOME/.config}/todo/config [ -e \"\$TODOTXT_CFG_FILE\" ] || TODOTXT_CFG_FILE=\${XDG_CONFIG_HOME:-\$HOME/.config}/todo/config
[ -e \"\$TODOTXT_CFG_FILE\" ] || TODOTXT_CFG_FILE=${(qqq)todo:h}/todo.cfg [ -e \"\$TODOTXT_CFG_FILE\" ] || TODOTXT_CFG_FILE=${(qqq)_p9k__todo_command:h}/todo.cfg
[ -e \"\$TODOTXT_CFG_FILE\" ] || TODOTXT_CFG_FILE=\${TODOTXT_GLOBAL_CFG_FILE:-/etc/todo/config} [ -e \"\$TODOTXT_CFG_FILE\" ] || TODOTXT_CFG_FILE=\${TODOTXT_GLOBAL_CFG_FILE:-${(qqq)todo_global}}
[ -r \"\$TODOTXT_CFG_FILE\" ] || exit [ -r \"\$TODOTXT_CFG_FILE\" ] || exit
source \"\$TODOTXT_CFG_FILE\" &>/dev/null source \"\$TODOTXT_CFG_FILE\"
echo \"\$TODO_FILE\"")" printf "%s" \"\$TODO_FILE\" >&3")"
fi fi
fi fi