1 if ! (( $+commands[curl] )); then
2 echo "rand-quote plugin needs curl to work" >&2
7 setopt localoptions nopromptsubst
9 # Get random quote data
11 data="$(command curl -s --connect-timeout 2 "http://www.quotationspage.com/random.php" \
12 | iconv -c -f ISO-8859-1 -t UTF-8 \
13 | command grep -a -m 1 'dt class="quote"')"
15 # Exit if could not fetch random quote
16 [[ -n "$data" ]] || return 0
19 quote=$(sed -e 's|</dt>.*||g' -e 's|.*html||g' -e 's|^[^a-zA-Z]*||' -e 's|</a..*$||g' <<< "$data")
20 author=$(sed -e 's|.*/quotes/||g' -e 's|<.*||g' -e 's|.*">||g' <<< "$data")
22 print -P "%F{3}${author}%f: â%F{5}${quote}%fâ"