Created
June 27, 2018 22:01
-
-
Save onjin/2ed25400da94d5c2ed7e27311e353290 to your computer and use it in GitHub Desktop.
display hints from devhints.io
This file contains 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
#!/usr/bin/env bash | |
type wget >/dev/null 2>&1 || { echo >&2 "I require wget but it's not installed."; exit 1; } | |
type mdless >/dev/null 2>&1 || { echo >&2 "I require mdless but it's not installed. sudo gem install mdless"; exit 1; } | |
TOOL=${1:?Usage: $0 <toolname> [--refresh]} | |
REFRESH=${2:-no} | |
RAW_MD_URL="https://raw.github.com/hazeorid/devhints.io/gh-pages/${TOOL}.md" | |
CACHE_DIR=$HOME/.devhints/ | |
LOCAL_CACHE_FILE=$CACHE_DIR/${TOOL}.md | |
if [ ! -d $CACHE_DIR ]; then | |
mkdir -p $CACHE_DIR | |
fi | |
if [ "$REFRESH" == "--refresh" ] || [ ! -e $LOCAL_CACHE_FILE ]; then | |
wget -q -O - $RAW_MD_URL | sed -e '/^{: /d' > $LOCAL_CACHE_FILE | |
fi | |
if [ -s $LOCAL_CACHE_FILE ]; then | |
mdless $LOCAL_CACHE_FILE 2>/dev/null | |
else | |
echo No cheat sheet found! | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment