diff options
author | Tuowen Zhao <ztuowen@gmail.com> | 2020-01-02 15:46:19 -0500 |
---|---|---|
committer | Tuowen Zhao <ztuowen@gmail.com> | 2020-01-02 15:46:19 -0500 |
commit | ff9208623b3573c736ae9118947aaf0c7e752998 (patch) | |
tree | 45977b00446155003d486c04c3b891a5b7c88441 /plugins/hitokoto/hitokoto.plugin.zsh | |
parent | 1456610ebd292625fdc34fa3167c9c0f67d85228 (diff) | |
parent | ca627655dbd1d110dbea34ec4a8c1964a1da83d2 (diff) | |
download | zsh-ff9208623b3573c736ae9118947aaf0c7e752998.tar.gz zsh-ff9208623b3573c736ae9118947aaf0c7e752998.tar.bz2 zsh-ff9208623b3573c736ae9118947aaf0c7e752998.zip |
Merge branch 'master' of https://github.com/ohmyzsh/ohmyzsh
Diffstat (limited to 'plugins/hitokoto/hitokoto.plugin.zsh')
-rw-r--r-- | plugins/hitokoto/hitokoto.plugin.zsh | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/plugins/hitokoto/hitokoto.plugin.zsh b/plugins/hitokoto/hitokoto.plugin.zsh new file mode 100644 index 000000000..8646ebf3b --- /dev/null +++ b/plugins/hitokoto/hitokoto.plugin.zsh @@ -0,0 +1,14 @@ +if ! (( $+commands[curl] )); then + 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') + + TXT=$(echo "$Q" | awk -F '\t' '{print $1}') + WHO=$(echo "$Q" | awk -F '\t' '{print $2}') + + [[ -n "$WHO" && -n "$TXT" ]] && print -P "%F{3}${WHO}%f: â%F{5}${TXT}%fâ" +} |