Last active
August 29, 2015 14:25
-
-
Save ype/b4f2d58a1b4b1ea81163 to your computer and use it in GitHub Desktop.
Unix Tips from the interwebs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# To show everytime your shell opens add this function to the bottom of your bash_profile,bashrc,zshrc | |
function unix_tip() { | |
while [ "$count" -ne 1 ]; do | |
type pandoc >/dev/null 2>&1 || { echo >&2 "Pandoc is required, but not installed. If you have homebrew try: brew install pandoc"; break; } | |
type xmlstarlet >/dev/null 2>&1 || { echo >&2 "xmlstarlet is required, but not installed. If you have homebrew try: brew install xmlstarlet"; break; } | |
ping -c1 8.8.8.8 >> /dev/null | |
if [ $? -eq 0 ]; then | |
curl -s https://raw.githubusercontent.com/jlevy/the-art-of-command-line/master/README.md \ | |
| pandoc -f markdown -t html \ | |
| xmlstarlet fo --html --dropdtd \ | |
| xmlstarlet sel -t -v "(html/body/ul/li[count(p)>0])[$RANDOM mod last()+1]" \ | |
| xmlstarlet unesc \ | |
| fmt -80 | |
count=1 | |
else | |
echo "Network Connection Required to Display Unix Tips\nAlternatively you can clone https://github.com/jlevy/the-art-of-command-line and replace the curl command with cat /path/to/the-art-of-command-line" | |
count=1 | |
fi | |
done | |
}; unix_tip |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment