Last active
August 29, 2015 14:13
-
-
Save samdmarshall/db653963479f1a281106 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 "" | |
if [ $lookup_name = $lookup_section ]; set open_string "x-man-page://$lookup_name"; set grep_string "$lookup_name("; end; | |
if [ $lookup_name != $lookup_section ]; set open_string "x-man-page://$lookup_section/$lookup_name"; set grep_string "$lookup_name($lookup_section)"; end; | |
if man -k "$lookup_name" | grep -q "$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
msp@Slim ~> man -k printf | grep -E "printf(3)" -c
6
msp@Slim ~> man -k printf | grep -E "(^|[ \t\r\n\f])printf(3)" -c
3