From 31990a7dd0d796c4a82810dc556c85564cb59100 Mon Sep 17 00:00:00 2001 From: Christopher Hiller Date: Sat, 9 Aug 2014 19:48:08 -0700 Subject: [PATCH] man -> Dash.app integration for OS X --- plugins/available/dash.plugin.bash | 44 ++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 plugins/available/dash.plugin.bash diff --git a/plugins/available/dash.plugin.bash b/plugins/available/dash.plugin.bash new file mode 100644 index 00000000..56f679fa --- /dev/null +++ b/plugins/available/dash.plugin.bash @@ -0,0 +1,44 @@ +# Open manpages in Dash.app via: +# +# man +# +cite about-plugin +about-plugin "Dash.app Man Pages Integration" + +# To override the DocSet shortcut Man Pages name, export DASH_MAN_DOCSET somewhere. +DASH_MAN_DOCSET=${DASH_MAN_DOCSET-manpages} + +if [[ `uname` != Darwin ]]; then + echo The Dash.app plugin is only available on Mac OS X. Sorry! + exit +elif [[ ! -d /Applications/Dash.app ]]; then + echo To use the Dash.app plugin, install Dash.app from http://kapeli.com/dash + exit +elif [[ ! -d "$HOME/Library/Application Support/Dash/DocSets/Man_Pages" ]]; then + echo To use the Dash.app plugin, install the "Man Pages" DocSet from within Dash.app. + exit +else + # http://stackoverflow.com/questions/296536/urlencode-from-a-bash-script + # this enables to search multiple strings; "man git fetch" will find the "git" page and search for "fetch" within + function rawurlencode() { + local string="${@}" + local strlen=${#string} + local encoded="" + + for (( pos=0 ; pos