Update 30.01.2022

This commit is contained in:
2022-01-30 00:39:21 +05:00
parent 3d6a64111c
commit 04423b8c5c
323 changed files with 44877 additions and 7114 deletions

View File

@@ -1,14 +1,18 @@
if ! (( $+commands[curl] )); then
echo "hitokoto plugin needs curl to work" >&2
return
echo "hitokoto plugin needs curl to work" >&2
return
fi
function hitokoto {
emulate -L zsh
Q=$(curl -s --connect-timeout 2 "https://v1.hitokoto.cn" | jq -j '.hitokoto+"\t"+.from')
setopt localoptions nopromptsubst
TXT=$(echo "$Q" | awk -F '\t' '{print $1}')
WHO=$(echo "$Q" | awk -F '\t' '{print $2}')
# Get hitokoto data
local -a data
data=("${(ps:\n:)"$(command curl -s --connect-timeout 2 "https://v1.hitokoto.cn" | command jq -j '.hitokoto+"\n"+.from')"}")
[[ -n "$WHO" && -n "$TXT" ]] && print -P "%F{3}${WHO}%f: “%F{5}${TXT}%f”"
# Exit if could not fetch hitokoto
[[ -n "$data" ]] || return 0
local quote="${data[1]}" author="${data[2]}"
print -P "%F{3}${author}%f: “%F{5}${quote}%f”"
}