Forked from samdmarshall/gist:db653963479f1a281106
Last active
August 29, 2015 14:13
-
-
Save zorgiepoo/21188981e90b2a9641d2 to your computer and use it in GitHub Desktop.
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 xman | |
set lookup_name "$argv[-1]" | |
set lookup_section "$argv[1]" | |
set open_string "" | |
set grep_string "" | |
set beginning_pattern "(^|[ \t\r\n\f])" | |
if [ $lookup_name = $lookup_section ]; set open_string "x-man-page://$lookup_name"; set grep_string "$beginning_pattern$lookup_name\\("; end; | |
if [ $lookup_name != $lookup_section ]; set open_string "x-man-page://$lookup_section/$lookup_name"; set grep_string "$beginning_pattern$lookup_name\\($lookup_section\\)"; end; | |
if man -k "$lookup_name" | grep -q -E "$grep_string" > /dev/null | |
open "$open_string" | |
else | |
echo "No man page found!" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment