From 00e12b7a98ceefc42090361315ddf2a72b3e2fe6 Mon Sep 17 00:00:00 2001 From: Sorin Ionescu Date: Tue, 21 May 2013 13:46:42 -0400 Subject: [PATCH] Add capability to browse man pages in Dash.app --- modules/osx/README.md | 3 ++- .../osx/functions/{_manb => _manb_mand_manp} | 4 ++-- modules/osx/functions/mand | 21 +++++++++++++++++++ 3 files changed, 25 insertions(+), 3 deletions(-) rename modules/osx/functions/{_manb => _manb_mand_manp} (63%) create mode 100644 modules/osx/functions/mand diff --git a/modules/osx/README.md b/modules/osx/README.md index 1a63e5e..aace73c 100644 --- a/modules/osx/README.md +++ b/modules/osx/README.md @@ -15,6 +15,7 @@ Aliases Functions --------- + - `mand` opens _man_ pages in [_Dash.app_][2]. - `manp` opens _man_ pages in _Preview.app_. - `pfd` prints the current _Finder_ directory. - `pfs` prints the current _Finder_ selection. @@ -28,6 +29,6 @@ Authors - [Sorin Ionescu](https://github.com/sorin-ionescu) [1]: http://www.apple.com/macosx/ +[2]: http://kapeli.com/dash [3]: http://www.iterm2.com/ [4]: https://github.com/sorin-ionescu/prezto/issues - diff --git a/modules/osx/functions/_manb b/modules/osx/functions/_manb_mand_manp similarity index 63% rename from modules/osx/functions/_manb rename to modules/osx/functions/_manb_mand_manp index b3e551f..ae5630f 100644 --- a/modules/osx/functions/_manb +++ b/modules/osx/functions/_manb_mand_manp @@ -1,8 +1,8 @@ -#compdef manp +#compdef mand manp #autoload # -# Completes manp. +# Completes mand and manp. # # Authors: # Sorin Ionescu diff --git a/modules/osx/functions/mand b/modules/osx/functions/mand new file mode 100644 index 0000000..a22114e --- /dev/null +++ b/modules/osx/functions/mand @@ -0,0 +1,21 @@ +# +# Opens man pages in Dash.app. +# +# Authors: +# Sorin Ionescu +# + +function mand { + if (( $# > 0 )); then + open "dash://manpages:$1" 2>/dev/null + if (( $? != 0 )); then + print "$0: Dash is not installed" >&2 + break + fi + else + print 'What manual page do you want?' >&2 + fi +} + +mand "$@" +