summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config/p10k-classic.zsh8
-rw-r--r--config/p10k-lean-8colors.zsh8
-rw-r--r--config/p10k-lean.zsh8
-rw-r--r--config/p10k-rainbow.zsh9
-rw-r--r--internal/icons.zsh5
-rw-r--r--internal/p10k.zsh60
6 files changed, 98 insertions, 0 deletions
diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh
index c2af751e..5313752f 100644
--- a/config/p10k-classic.zsh
+++ b/config/p10k-classic.zsh
@@ -85,6 +85,7 @@
# ram # free RAM
# swap # used swap
todo # todo items (https://github.com/todotxt/todo.txt-cli)
+ timewarrior # timewarrior tracking status (https://timewarrior.net/)
# time # current time
# =========================[ Line #2 ]=========================
newline
@@ -627,6 +628,13 @@
# Custom icon.
# typeset -g POWERLEVEL9K_TODO_VISUAL_IDENTIFIER_EXPANSION='⭐'
+ ###########[ timewarrior: timewarrior tracking status (https://timewarrior.net/) ]############
+ # Timewarrior color.
+ typeset -g POWERLEVEL9K_TIMEWARRIOR_FOREGROUND=110
+
+ # Custom icon.
+ # typeset -g POWERLEVEL9K_TIMEWARRIOR_VISUAL_IDENTIFIER_EXPANSION='⭐'
+
##################################[ context: user@hostname ]##################################
# Context color when running with privileges.
typeset -g POWERLEVEL9K_CONTEXT_ROOT_FOREGROUND=178
diff --git a/config/p10k-lean-8colors.zsh b/config/p10k-lean-8colors.zsh
index f32d82fc..b6c8cb38 100644
--- a/config/p10k-lean-8colors.zsh
+++ b/config/p10k-lean-8colors.zsh
@@ -84,6 +84,7 @@
# ram # free RAM
# swap # used swap
todo # todo items (https://github.com/todotxt/todo.txt-cli)
+ timewarrior # timewarrior tracking status (https://timewarrior.net/)
# time # current time
# =========================[ Line #2 ]=========================
newline
@@ -606,6 +607,13 @@
# Custom icon.
# typeset -g POWERLEVEL9K_TODO_VISUAL_IDENTIFIER_EXPANSION='⭐'
+ ###########[ timewarrior: timewarrior tracking status (https://timewarrior.net/) ]############
+ # Timewarrior color.
+ typeset -g POWERLEVEL9K_TIMEWARRIOR_FOREGROUND=4
+
+ # Custom icon.
+ # typeset -g POWERLEVEL9K_TIMEWARRIOR_VISUAL_IDENTIFIER_EXPANSION='⭐'
+
##################################[ context: user@hostname ]##################################
# Context color when running with privileges.
typeset -g POWERLEVEL9K_CONTEXT_ROOT_FOREGROUND=1
diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh
index 30846e52..6457c662 100644
--- a/config/p10k-lean.zsh
+++ b/config/p10k-lean.zsh
@@ -84,6 +84,7 @@
# ram # free RAM
# swap # used swap
todo # todo items (https://github.com/todotxt/todo.txt-cli)
+ timewarrior # timewarrior tracking status (https://timewarrior.net/)
# time # current time
# =========================[ Line #2 ]=========================
newline
@@ -606,6 +607,13 @@
# Custom icon.
# typeset -g POWERLEVEL9K_TODO_VISUAL_IDENTIFIER_EXPANSION='⭐'
+ ###########[ timewarrior: timewarrior tracking status (https://timewarrior.net/) ]############
+ # Timewarrior color.
+ typeset -g POWERLEVEL9K_TIMEWARRIOR_FOREGROUND=110
+
+ # Custom icon.
+ # typeset -g POWERLEVEL9K_TIMEWARRIOR_VISUAL_IDENTIFIER_EXPANSION='⭐'
+
##################################[ context: user@hostname ]##################################
# Context color when running with privileges.
typeset -g POWERLEVEL9K_CONTEXT_ROOT_FOREGROUND=178
diff --git a/config/p10k-rainbow.zsh b/config/p10k-rainbow.zsh
index 658c2b1f..18059ec1 100644
--- a/config/p10k-rainbow.zsh
+++ b/config/p10k-rainbow.zsh
@@ -85,6 +85,7 @@
# ram # free RAM
# swap # used swap
todo # todo items (https://github.com/todotxt/todo.txt-cli)
+ timewarrior # timewarrior tracking status (https://timewarrior.net/)
# time # current time
# =========================[ Line #2 ]=========================
newline
@@ -637,6 +638,14 @@
# Custom icon.
# typeset -g POWERLEVEL9K_TODO_VISUAL_IDENTIFIER_EXPANSION='⭐'
+ ###########[ timewarrior: timewarrior tracking status (https://timewarrior.net/) ]############
+ # Timewarrior color.
+ # typeset -g POWERLEVEL9K_TIMEWARRIOR_FOREGROUND=255
+ # typeset -g POWERLEVEL9K_TIMEWARRIOR_BACKGROUND=8
+
+ # Custom icon.
+ # typeset -g POWERLEVEL9K_TIMEWARRIOR_VISUAL_IDENTIFIER_EXPANSION='⭐'
+
##################################[ context: user@hostname ]##################################
# Context color when running with privileges.
typeset -g POWERLEVEL9K_CONTEXT_ROOT_FOREGROUND=1
diff --git a/internal/icons.zsh b/internal/icons.zsh
index 63e9e2e4..a96b747c 100644
--- a/internal/icons.zsh
+++ b/internal/icons.zsh
@@ -123,6 +123,7 @@ function _p9k_init_icons() {
LUA_ICON 'lua'
PERL_ICON 'perl'
NNN_ICON 'nnn'
+ TIMEWARRIOR_ICON 'tw'
)
;;
'awesome-fontconfig')
@@ -233,6 +234,7 @@ function _p9k_init_icons() {
LUA_ICON 'lua'
PERL_ICON 'perl'
NNN_ICON 'nnn'
+ TIMEWARRIOR_ICON 'tw'
)
;;
'awesome-mapped-fontconfig')
@@ -347,6 +349,7 @@ function _p9k_init_icons() {
LUA_ICON 'lua'
PERL_ICON 'perl'
NNN_ICON 'nnn'
+ TIMEWARRIOR_ICON 'tw'
)
;;
'nerdfont-complete'|'nerdfont-fontconfig')
@@ -458,6 +461,7 @@ function _p9k_init_icons() {
LUA_ICON '\uE620' # 
PERL_ICON '\uE769' # 
NNN_ICON 'nnn'
+ TIMEWARRIOR_ICON '\uF132' # 
)
;;
*)
@@ -568,6 +572,7 @@ function _p9k_init_icons() {
LUA_ICON 'lua'
PERL_ICON 'perl'
NNN_ICON 'nnn'
+ TIMEWARRIOR_ICON 'tw'
)
;;
esac
diff --git a/internal/p10k.zsh b/internal/p10k.zsh
index 7c80337d..062adf74 100644
--- a/internal/p10k.zsh
+++ b/internal/p10k.zsh
@@ -4255,6 +4255,63 @@ function instant_prompt_direnv() {
fi
}
+function prompt_timewarrior() {
+ local -a stat
+ if [[ -n $_p9k_timewarrior_file_name ]]; then
+ zstat -A stat +mtime -- ~/.timewarrior/data $_p9k_timewarrior_file_name 2>/dev/null || stat=()
+ if [[ $stat[1] == $_p9k_timewarrior_dir_mtime && $stat[2] == $_p9k_timewarrior_file_mtime ]]; then
+ if (( $+_p9k_timewarrior_tags )); then
+ _p9k_prompt_segment $0 grey 255 TIMEWARRIOR_ICON 0 '' "${_p9k_timewarrior_tags//\%/%%}"
+ fi
+ return
+ fi
+ fi
+ if [[ ! -d ~/.timewarrior/data ]]; then
+ _p9k_timewarrior_dir_mtime=0
+ _p9k_timewarrior_file_mtime=0
+ _p9k_timewarrior_file_name=
+ unset _p9k_timewarrior_tags
+ return
+ fi
+ if [[ $stat[1] != $_p9k_timewarrior_dir_mtime ]]; then
+ local -a files=(~/.timewarrior/data/<->-<->.data(.N))
+ if (( ! $#files )); then
+ if (( $#stat )) || zstat -A stat +mtime -- ~/.timewarrior/data 2>/dev/null; then
+ _p9k_timewarrior_dir_mtime=$stat[1]
+ _p9k_timewarrior_file_mtime=$stat[1]
+ _p9k_timewarrior_file_name=~/.timewarrior/data
+ else
+ _p9k_timewarrior_dir_mtime=0
+ _p9k_timewarrior_file_mtime=0
+ _p9k_timewarrior_file_name=
+ fi
+ unset _p9k_timewarrior_tags
+ return
+ fi
+ _p9k_timewarrior_file_name=${${(AO)files}[1]}
+ fi
+ if ! zstat -A stat +mtime -- ~/.timewarrior/data $_p9k_timewarrior_file_name 2>/dev/null; then
+ _p9k_timewarrior_dir_mtime=0
+ _p9k_timewarrior_file_mtime=0
+ _p9k_timewarrior_file_name=
+ unset _p9k_timewarrior_tags
+ return
+ fi
+ _p9k_timewarrior_dir_mtime=$stat[1]
+ _p9k_timewarrior_file_mtime=$stat[2]
+ { local tail=${${(Af)"$(<$_p9k_timewarrior_file_name)"}[-1]} } 2>/dev/null
+ if [[ $tail == (#b)'inc '[^\ ]##(|\ #\#(*)) ]]; then
+ _p9k_timewarrior_tags=${${match[2]## #}%% #}
+ _p9k_prompt_segment $0 grey 255 TIMEWARRIOR_ICON 0 '' "${_p9k_timewarrior_tags//\%/%%}"
+ else
+ unset _p9k_timewarrior_tags
+ fi
+}
+
+function _p9k_prompt_timewarrior_init() {
+ typeset -g "_p9k__segment_cond_${_p9k_prompt_side}[_p9k_segment_index]"='$commands[timew]'
+}
+
# Use two preexec hooks to survive https://github.com/MichaelAquilina/zsh-you-should-use with
# YSU_HARDCORE=1. See https://github.com/romkatv/powerlevel10k/issues/427.
_p9k_preexec1() {
@@ -5307,6 +5364,9 @@ typeset -g _p9k__param_pat
typeset -g _p9k__param_sig
_p9k_init_vars() {
+ typeset -gi _p9k_timewarrior_dir_mtime
+ typeset -gi _p9k_timewarrior_file_mtime
+ typeset -g _p9k_timewarrior_file_name
typeset -ga _p9k__prompt_char_saved
typeset -g _p9k__worker_pid
typeset -g _p9k__worker_req_fd