diff --git a/powerlevel-config/segments/prompt_c_twitch b/powerlevel-config/segments/prompt_c_twitch new file mode 100644 index 0000000..dd535c8 --- /dev/null +++ b/powerlevel-config/segments/prompt_c_twitch @@ -0,0 +1,10 @@ +local cachefile=~/.cache/twitch +[ -r $cachefile ] || return +local -a stats +zstat -A stats +mtime -- $cachefile 2>/dev/null +if [ "${_cprompts_twitch[2]:-1}" -ne "${stats[1]:-0}" ]; then + local IFS=$'\n' + local streaming=($(< $cachefile)) + typeset -g _cprompts_twitch=(${#streaming} $stats[1]) +fi +[ ${_cprompts_twitch[1]} -gt 0 ] && p10k segment -b purple -i '' -t "${_cprompts_twitch[1]:-unknown}" diff --git a/powerlevel-config/segments/prompt_c_uircd b/powerlevel-config/segments/prompt_c_uircd new file mode 100644 index 0000000..c26f4b2 --- /dev/null +++ b/powerlevel-config/segments/prompt_c_uircd @@ -0,0 +1,14 @@ +local REPLY +local NICK +zstyle -s ':custom:prompts:uircd' nick NICK +zstyle -s ':custom:prompts:uircd' glob REPLY +local files=(${~REPLY}(.N)) +local filtered=() +for i in $files; do + local IFS=$'\n' + local lines=($(tail -n100 $i)) + filtered+=( ${(M)lines:#@time=$(date '+%F')* PRIVMSG * :*${NICK}*} ) +done +typeset -g _cprompts_mentions_count=${#${(u)filtered}} +[[ ${_cprompts_mentions_count} -gt 0 ]] || return +p10k segment -b red -i '' -t "${_cprompts_mentions_count:-unknown}" diff --git a/preferences.zsh b/preferences.zsh index 54ab3ea..c08318e 100644 --- a/preferences.zsh +++ b/preferences.zsh @@ -32,7 +32,7 @@ fi zstyle -s ':custom:preferences' prompt _cur_prompt if [[ $_cur_prompt == "p9k" ]] && [[ -r "${ZDOTDIR}/powerlevel10k/powerlevel10k.zsh-theme" ]]; then fpath+=("${ZDOTDIR}/powerlevel-config/segments") - function {prompt_c_{covid_19,docker_host,mpv,new_mail,todo,weather,newsboat,mumble,sfeed},cprompts:cache:async:{covid,weather,rss}}() { + function {prompt_c_{covid_19,docker_host,mpv,new_mail,todo,weather,newsboat,mumble,sfeed,uircd,twitch},cprompts:cache:async:{covid,weather,rss}}() { autoload -X } source ${ZDOTDIR}/powerlevel-config/all.zsh