Improve caching, reduce disk reads (even if they are cached), add weather segment and change the way the prompt is shown
This commit is contained in:
parent
d071a9becc
commit
3d39188b35
@ -35,6 +35,7 @@ function getnhentai {
|
||||
}
|
||||
function gethanime {
|
||||
local IDS=($(curl -sSL "https://members.hanime.tv/api/v3/videos_manifests/$1" -H 'x-directive: api' | jq -e '.videos_manifest.servers[].streams | sort_by(.width) | .[].id'))
|
||||
[ ! -z $2 ] && print "https://hanime.tv/api/v1/m3u8s/$i.m3u8" && return
|
||||
for i in $IDS; do
|
||||
[ ! -z $i ] && ffmpeg -i "https://hanime.tv/api/v1/m3u8s/$i.m3u8" -c:v copy ${2:-$1.mkv} && break
|
||||
done
|
||||
|
@ -4,17 +4,65 @@ function prompt_docker_host() {
|
||||
}
|
||||
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}"
|
||||
[ -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:-\?}"
|
||||
}
|
||||
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
|
||||
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')
|
||||
[ ! -z $_cprompts_covid ] && print $_cprompts_covid > $tmpfile
|
||||
else
|
||||
typeset -g _cprompts_covid=$(< $tmpfile)
|
||||
fi
|
||||
fi
|
||||
p10k segment -b red -i '' -t "$(< $tmpfile)"
|
||||
p10k segment -b red -i '' -t "${_cprompts_covid:-unknown}"
|
||||
}
|
||||
function prompt_weather() {
|
||||
local tmpfile=~/.cache/weather
|
||||
local -a stats
|
||||
|
||||
# Fancy stuff
|
||||
local -A icons
|
||||
local -A colors
|
||||
icons[c]=''
|
||||
colors[c]="yellow"
|
||||
icons[lc]=''
|
||||
colors[lc]="yellow"
|
||||
icons[hc]=''
|
||||
colors[hc]="cyan"
|
||||
icons[s]=''
|
||||
colors[s]="cyan"
|
||||
icons[lr]=''
|
||||
colors[lr]="cyan"
|
||||
icons[hr]=''
|
||||
colors[hr]="cyan"
|
||||
icons[t]=''
|
||||
colors[t]="white"
|
||||
icons[h]=''
|
||||
colors[h]="blue"
|
||||
icons[sl]=''
|
||||
colors[sl]="blue"
|
||||
icons[sn]=''
|
||||
colors[sn]="white"
|
||||
|
||||
if [ -v ${_cprompts_weather[1]} ]; then
|
||||
typeset -g _cprompts_weather
|
||||
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]:-?})
|
||||
print $_cprompts_weather > $tmpfile
|
||||
fi
|
||||
else
|
||||
_cprompts_weather=($(< $tmpfile))
|
||||
fi
|
||||
fi
|
||||
p10k segment -b ${_cprompts_weather[2]:-red} -i ${_cprompts_weather[3]:-\?} -t "${_cprompts_weather[1]:-unknown}"
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ setopt appendhistory autocd auto_pushd extendedglob nomatch notify hist_ignore_a
|
||||
|
||||
typeset -g POWERLEVEL9K_DISABLE_HOT_RELOAD=true
|
||||
typeset -g POWERLEVEL9K_MODE='nerdfont-fontconfig'
|
||||
if [ -z "$SSH_CONNECTION" ] && ! [ -z "$DISPLAY" ]; then
|
||||
if [[ $_set_prompt == "p9k" ]]; then
|
||||
source ${ZDOTDIR}/powerlevel10k/powerlevel10k.zsh-theme
|
||||
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
|
||||
typeset -g POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(
|
||||
@ -29,6 +29,7 @@ if [ -z "$SSH_CONNECTION" ] && ! [ -z "$DISPLAY" ]; then
|
||||
background_jobs
|
||||
vim_shell
|
||||
new_mail
|
||||
weather
|
||||
covid_19
|
||||
public_ip
|
||||
newline
|
||||
|
Loading…
Reference in New Issue
Block a user