Skip to content

Instantly share code, notes, and snippets.

@psynaptic
Created March 10, 2014 21:12
Show Gist options
  • Save psynaptic/9474436 to your computer and use it in GitHub Desktop.
Save psynaptic/9474436 to your computer and use it in GitHub Desktop.
function wiki() {
red='\e[0;31m'
yellow='\e[0;33m'
cyan='\e[0;36m'
search=$(echo $@ | sed -e 's/ /_/g')
blob=$(dig +short txt ${search}.wp.dg.cx)
if [ -z "$blob" ]; then
echo "${red}No result found."
return 1
fi
# Clean up the blob.
blob=$(echo "$blob" | sed -e 's/ //256' -e 's/" "//g' -e 's/\\"/"/g' -e 's/^"//' -e 's/"$//' -e 's/ / /g')
url=$(echo "$blob" | grep -o 'http://.*')
text=$(echo "$blob" | sed -e "s@$url@@" -e 's/ $//')
echo "${yellow}$text"
echo "${cyan}$url"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment