2006-02-15 10:22:28 +08:00
|
|
|
|
2010-09-18 10:18:26 +08:00
|
|
|
function __fish_complete_man
|
2006-02-15 10:22:28 +08:00
|
|
|
if test (commandline -ct)
|
|
|
|
|
|
|
|
# Try to guess what section to search in. If we don't know, we
|
|
|
|
# use [^)]*, which should match any section
|
|
|
|
|
|
|
|
set section ""
|
|
|
|
set prev (commandline -poc)
|
|
|
|
set -e prev[1]
|
|
|
|
while count $prev
|
|
|
|
switch $prev[1]
|
|
|
|
case '-**'
|
2010-09-18 10:18:26 +08:00
|
|
|
|
2006-02-15 10:22:28 +08:00
|
|
|
case '*'
|
|
|
|
set section $prev[1]
|
|
|
|
end
|
|
|
|
set -e prev[1]
|
|
|
|
end
|
2010-09-18 10:18:26 +08:00
|
|
|
|
2006-02-15 10:22:28 +08:00
|
|
|
set section $section"[^)]*"
|
|
|
|
|
|
|
|
# Do the actual search
|
2006-11-29 22:00:04 +08:00
|
|
|
apropos (commandline -ct) | sgrep \^(commandline -ct) | sed -n -e 's/\([^ ]*\).*(\('$section'\)) *- */\1'\t'\2: /p'
|
2006-02-15 10:22:28 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|