37be62ffb7856cda96a187f4acf79afe2fed2514

Author
Eduardo San Martin Morote <posva13@gmail.com>
Committer
Eduardo San Martin Morote <posva13@gmail.com>
Date

Message

randquote plugin
correcting an issue about encoding some people was having
added a message when the user doesn't have curl
added varibles for colors->easier to customize

Diff

 1diff --git a/plugins/rand-quote/rand-quote.plugin.zsh b/plugins/rand-quote/rand-quote.plugin.zsh
 2index 5544ca565777cd06cc58cc9833399e628a7090d2..c3bf6234ec61157034f1080d3bed8c1257a2f551 100644
 3--- a/plugins/rand-quote/rand-quote.plugin.zsh
 4+++ b/plugins/rand-quote/rand-quote.plugin.zsh
 5@@ -5,13 +5,24 @@
 6 # Don't remove this header, thank you
 7 # Usage: quote
 8 
 9+WHO_COLOR="\e[0;33m"
10+TEXT_COLOR="\e[0;35m"
11+COLON_COLOR="\e[0;35m"
12+END_COLOR="\e[m"
13+
14 if [[ -x `which curl` ]]; then
15     function quote()
16     {
17-        Q=$(curl -s --connect-timeout 2 "http://www.quotationspage.com/random.php3" | grep -m 1 "dt ")
18+        Q=$(curl -s --connect-timeout 2 "http://www.quotationspage.com/random.php3" | iconv -c -f ISO-8859-1 -t UTF-8 | grep -m 1 "dt ")
19         TXT=$(echo "$Q" | sed -e 's/<\/dt>.*//g' -e 's/.*html//g' -e 's/^[^a-zA-Z]*//' -e 's/<\/a..*$//g')
20         W=$(echo "$Q" | sed -e 's/.*\/quotes\///g' -e 's/<.*//g' -e 's/.*">//g')
21-        echo "\e[0;33m${W}\e[0;30m: \e[0;35m“${TXT}”\e[m"
22+        if [ "$W" -a "$TXT" ]; then
23+          echo "${WHO_COLOR}${W}${COLON_COLOR}: ${TEXT_COLOR}“${TXT}”${END_COLOR}"
24+        else
25+          quote
26+        fi
27     }
28     #quote
29+else
30+    echo "rand-quote plugin needs curl to work" >&2
31 fi