Skip to content

Instantly share code, notes, and snippets.

@taviso
Created July 12, 2019 22:30
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taviso/b6a70dc55c14d8fb9259a2a351d0acf8 to your computer and use it in GitHub Desktop.
Save taviso/b6a70dc55c14d8fb9259a2a351d0acf8 to your computer and use it in GitHub Desktop.
Read MSDN pages in a terminal.
# man equivalent for msdn pages so I can look them up in the console.
function msdn()
{
local lucky="https://www.google.com/search?btnI"
local query="q=site:docs.microsoft.com+inurl:/en-us/windows/desktop/"
local title="Microsoft Developer Network"
local cache="${HOME}/.msdn/"
if ! type lynx > /dev/null; then
echo "error: lynx is not installed, please install it." 1>&2
return
fi
if ! test -f "${cache}/${1,,}.gz"; then
mkdir -p "${cache}"
if ! lynx -nolist -dump "${lucky}&${query}+${1}" > "${cache}/${1,,}"; then
rm -f "${cache}/${1,,}"
return
fi
gzip "${cache}/${1,,}"
fi
zless -isP "s${title} - ${1}" "+/^${1,,}" "${cache}/${1,,}.gz"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment