Skip to content

Instantly share code, notes, and snippets.

@taviso
Created Jul 12, 2019
Embed
What would you like to do?
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