aboutsummaryrefslogtreecommitdiffhomepage
path: root/share/functions/__fish_complete_man.fish
blob: 7be041f0ceded52132d5ec50cbe8b5ddd8b71d5f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27

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) | sgrep \^(commandline -ct) | sed -n -e 's/\([^ ]*\).*(\('$section'\)) *- */\1'\t'\2: /p'
	end
end