Skip to content

Instantly share code, notes, and snippets.

@samdmarshall
Last active August 29, 2015 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save samdmarshall/db653963479f1a281106 to your computer and use it in GitHub Desktop.
Save samdmarshall/db653963479f1a281106 to your computer and use it in GitHub Desktop.
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
@zorgiepoo
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment