1 if ! (( $+commands[curl] )); then
2 echo "hitokoto plugin needs curl to work" >&2
7 setopt localoptions nopromptsubst
11 data=("${(ps:\n:)"$(command curl -s --connect-timeout 2 "https://v1.hitokoto.cn" | command jq -j '.hitokoto+"\n"+.from')"}")
13 # Exit if could not fetch hitokoto
14 [[ -n "$data" ]] || return 0
16 local quote="${data[1]}" author="${data[2]}"
17 print -P "%F{3}${author}%f: â%F{5}${quote}%fâ"