Some screenshots follows:
You get the idea right. Just that if I want to read another quote in terminal, I have to cd ~/<script folder> and ./getquote from there (I keep my scripts organized). I'm kinda lazy so I just Ctrl-Shift-T, Ctrl-Shift-W all the time. :p Works for me.
This is what I did. I have 2 main files:
- ./import - this one is for importing the quotes all at once from any of their RSS feed provider. Then I use xmlstarlet to extract information I need and format it the way I want (so painlessly, I might add). and then save it as plain text file.
# retrieve quotes from bash.org and save it to bashquotes.xml
# -one of the RSS provider http://quotes.sydv.net/
echo "Retrieving from bash.org..."
wget -O bashquotes.xml http://feeds2.feedburner.com/top100-bash-quotes
# extract the feed to file bashquotes
echo "Extracting RSS feed..."
xmlstarlet sel -t -m '//item' -o '==%%==' -v 'description' -n bashquotes.xml > bashquotes
echo "RSS feed saved in bashquotes"
# replacing html entities to proper character for viewing
sed 's/</' bashquotes > bashquotes2
sed 's/>/>/g' bashquotes2 > bashquotes
sed 's/<br />/n/g' bashquotes > bashquotes2
sed 's/"/"/g' bashquotes2 > bashquotes
sed 's/ / /g' bashquotes > bashquotes2
sed 's/<img.*>//g' bashquotes2 > bashquotes.txt
echo "bashquotes.txt ready"
- ./getquote - this one is for reading off that text file and get any one from the quote.
# reading from bashquotes.txt
quotes=($(cat bashquotes.txt)) # array
# form an array
for ((i=0; i
- To get it displayed in the terminal, I appended this in my ~/.bashrc
echo "--irc quotes--"
echo -e "================================"
Simple right. This is the result of me being blocked by an SVN server earlier on, that in a way has cut me off from doing any real work. Heh.
Now I know the code is not the most elegant, most of them are copy and paste and modified but all in all it's worth my time coz the quotes are just freakin hilarious!
Note: my terminal is a modified version of this - I had wanted to post about it when I did it but too lazy now.