ZSHFiles/custom/segments.zsh

21 lines
780 B
Bash
Raw Normal View History

typeset -gi _mail_count
2020-04-06 21:30:24 +00:00
function prompt_docker_host() {
p10k segment -b blue -i '' -t "${DOCKER_HOST#*://}" -c "${DOCKER_HOST#*://}"
2020-04-06 21:30:24 +00:00
}
typeset -g POWERLEVEL9K_DOCKER_HOST_SHOW_ON_COMMAND='docker'
function prompt_new_mail() {
_mail_count=(~/Mail/*/Inbox/new/*(.N))
(( ${#_mail_count} > 0 )) || return
p10k segment -b yellow -i '' -t "${#_mail_count}"
2020-04-06 21:30:24 +00:00
}
function prompt_covid_19() {
local tmpfile=~/.cache/covidres
local -a stats
zstat -A stats +mtime -- $tmpfile 2>/dev/null
if [[ $stats[1] < $(($epochtime[1]-86400)) ]]; then
local result=$(curl -sL https://api.covid19api.com/country/germany/status/confirmed/live | jq -e '. |= sort_by (.Date) | .[-1].Cases')
[ ! -z $result ] && print $result > $tmpfile
fi
p10k segment -b red -i '' -t "$(< $tmpfile)"
}