Tweak some stuff around and fix a few buggz

This commit is contained in:
Alex 2020-05-19 14:29:44 +02:00
parent 3d39188b35
commit 8f1494e08b
Signed by: caskd
GPG Key ID: F92BA85F61F4C173
2 changed files with 14 additions and 12 deletions

View File

@ -1,17 +1,19 @@
typeset -gi _mail_count
function prompt_docker_host() {
p10k segment -b blue -i '' -t "${DOCKER_HOST#*://}" -c "${DOCKER_HOST#*://}"
}
typeset -g POWERLEVEL9K_DOCKER_HOST_SHOW_ON_COMMAND='docker'
function prompt_new_mail() {
[ -v $_cprompts_mail_count ] && typeset -g _cprompts_mail_count=(~/Mail/*/Inbox/new/*(.N))
(( ${#_cprompts_mail_count} > 0 )) || return
p10k segment -b yellow -i '' -t "${#_cprompts_mail_count:-\?}"
if [ ! -v _cprompts_mail_count ]; then
local new_mails=(~/Mail/*/Inbox/new/*(.N))
typeset -g _cprompts_mail_count=${#new_mails}
fi
[[ ${_cprompts_mail_count} -gt 0 ]] || return
p10k segment -b yellow -i '' -t "${_cprompts_mail_count:-unknown}"
}
function prompt_covid_19() {
local tmpfile=~/.cache/covidres
local tmpfile=${CACHEPATH}/covid
local -a stats
if [ -v $_cprompts_covid ]; then
if [ ! -v _cprompts_covid ]; then
zstat -A stats +mtime -- $tmpfile 2>/dev/null
if [[ $stats[1] < $(($epochtime[1]-86400)) ]]; then
typeset -g _cprompts_covid=$(curl -sL https://api.covid19api.com/country/germany/status/confirmed/live | jq -e '. |= sort_by (.Date) | .[-1].Cases')
@ -23,7 +25,7 @@ function prompt_covid_19() {
p10k segment -b red -i '' -t "${_cprompts_covid:-unknown}"
}
function prompt_weather() {
local tmpfile=~/.cache/weather
local tmpfile=${CACHEPATH}/weather
local -a stats
# Fancy stuff
@ -50,19 +52,18 @@ function prompt_weather() {
icons[sn]=''
colors[sn]="white"
if [ -v ${_cprompts_weather[1]} ]; then
typeset -g _cprompts_weather
if [ ! -v _cprompts_weather ]; then
zstat -A stats +mtime -- $tmpfile 2>/dev/null
if [[ $stats[1] < $(($epochtime[1]-86400)) ]]; then
local result=$(curl -sL https://www.metaweather.com/api/location/${_cprompts_weather_loc:-1339615}/ | jq -e '.consolidated_weather[0] | {"temp": .the_temp, "icon": .weather_state_abbr}')
if [ ! -z $result ]; then
local ico=$(print $result | jq -r '.icon')
_cprompts_weather=($(print $result | jq -r '.temp') ${colors[$ico]} ${icons[$ico]:-?})
typeset -g _cprompts_weather=($(print $result | jq -r '.temp') ${colors[$ico]} ${icons[$ico]:-?})
print $_cprompts_weather > $tmpfile
fi
else
_cprompts_weather=($(< $tmpfile))
typeset -g _cprompts_weather=($(< $tmpfile))
fi
fi
p10k segment -b ${_cprompts_weather[2]:-red} -i ${_cprompts_weather[3]:-\?} -t "${_cprompts_weather[1]:-unknown}"
p10k segment -b ${_cprompts_weather[2]:-white} -i ${_cprompts_weather[3]:-\?} -t "${_cprompts_weather[1]:-unknown}"
}

View File

@ -1,4 +1,5 @@
typeset -g HISTFILE=~/.histfile
typeset -g CACHEPATH=~/.cache
typeset -g HISTSIZE=1000
typeset -g SAVEHIST=1000
typeset -g ZLE_RPROMPT_INDENT=0