Created
October 21, 2015 08:06
-
-
Save boneskull/4b6378784e2d719dd543 to your computer and use it in GitHub Desktop.
Open any man page (using "man") in Dash.app
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
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 | |
} |
It opens your man pages directly in Dash app.
Just go and integrate man plugin of Dash app. The plugin would read all pages available on your system. You can also search any Unix/Linux command in Dash app itself.
Or
Above .bash_profile addition would open man pages in Dash directly by hitting command directly in the terminal.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
After adding the above to
~/.bash_profile
, either restart your shell session or executesource ~/.bash_profile
. Then,man find
will open the man page forfind
in Dash.app.The
encodeuri
function, when combined with/usr/bin/open
, can assist in hitting all sorts of app-defined URI's. To see what's available on your system, a tool like RCDefaultApp is handy.