Skip to content

Instantly share code, notes, and snippets.

@ff6347
Forked from boneskull/.bash_profile
Created October 22, 2015 07:49
Show Gist options
  • Select an option

  • Save ff6347/dbab095231dc93ad5588 to your computer and use it in GitHub Desktop.

Select an option

Save ff6347/dbab095231dc93ad5588 to your computer and use it in GitHub Desktop.
Open any man page (using "man") in Dash.app
function encodeuri {
local string="${@}"
local strlen=${#string}
local encoded=""
for (( pos = 0; pos < strlen; pos ++ )); do
c=${string:$pos:1}
case "$c" in
[-_.~a-zA-Z0-9]) o="${c}" ;;
*) printf -v o '%%%02x' "'$c"
esac
encoded+="${o}"
done
echo "${encoded}"
}
function man {
if [[ -d /Applications/Dash.app && \
-d "$HOME/Library/Application Support/Dash/DocSets/Man_Pages" ]]; then
/usr/bin/open dash://manpages:`encodeuri ${@}`
else
/usr/bin/man ${@}
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment