fish-shell/share/functions/__fish_complete_man.fish
axel 3b6d8756ea Fix various uses of the GNUism of allowing backslash escapes in the second half of a sed regexp substitution
darcs-hash:20060302112808-ac50b-46cdf8e99f8f6e8cab0d54f32cf4e4d309775aa1.gz
2006-03-02 21:28:08 +10:00

27 lines
547 B
Fish

function __fish_complete_man
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 '-**'
case '*'
set section $prev[1]
end
set -e prev[1]
end
set section $section"[^)]*"
# Do the actual search
apropos (commandline -ct) | grep \^(commandline -ct) | sed -n -e 's/\([^ ]*\).*(\('$section'\)) *- */\1'\t'\2: /p'
end
end