[Bash-completion-commits] [SCM] bash-completion branch, master, updated. e6b7e5ec64e549f9ab7815517bd028831bee3515

David Paleino d.paleino at gmail.com
Fri Jun 5 06:43:27 UTC 2009


The following commit has been merged in the master branch:
commit e6b7e5ec64e549f9ab7815517bd028831bee3515
Author: David Paleino <d.paleino at gmail.com>
Date:   Fri Jun 5 08:43:11 2009 +0200

    Split man completion to contrib/man

diff --git a/CHANGES b/CHANGES
index f9c89d9..f93aea0 100644
--- a/CHANGES
+++ b/CHANGES
@@ -27,6 +27,7 @@ bash-completion (1.x)
   * Split apt-cache and apt-get completions to contrib/apt
   * Split rpm-related completions to contrib/rpm
   * Split cvs-related completions to contrib/cvs
+  * Split man completion to contrib/man
 
   [ Ville Skyttä ]
   * Split yum and yum-arch completion into contrib/yum.
diff --git a/Makefile.am b/Makefile.am
index 5ecaa64..1cd87a6 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -60,6 +60,7 @@ bashcomp_DATA = contrib/ant \
 		contrib/lvm \
 		contrib/lzop \
 		contrib/make \
+		contrib/man \
 		contrib/mc \
 		contrib/mailman \
 		contrib/mcrypt \
diff --git a/bash_completion b/bash_completion
index 94e4073..ee79116 100644
--- a/bash_completion
+++ b/bash_completion
@@ -1001,82 +1001,6 @@ _insmod()
 complete -F _insmod $filenames insmod modprobe modinfo
 }
 
-# man(1) completion
-#
-[ $USERLAND = GNU -o $UNAME = Darwin \
-  -o $UNAME = FreeBSD -o $UNAME = SunOS -o $UNAME = Cygwin \
-  -o $UNAME = OpenBSD ] &&
-_man()
-{
-	local cur prev sect manpath manext mansect uname
-
-	manext="@([0-9lnp]|[0-9][px]|man|3pm)?(.@(gz|bz2|lzma))"
-	mansect="@([0-9lnp]|[0-9][px]|3pm)"
-
-	COMPREPLY=()
-	cur=`_get_cword`
-	prev=${COMP_WORDS[COMP_CWORD-1]}
-	
-	if [[ "$prev" == -l ]]; then
-		_filedir $manext
-		return 0
-	fi
-
-	_expand || return 0
-
-	# file based completion if parameter contains /
-	if [[ "$cur" == */* ]]; then
-		_filedir $manext
-		return 0
-	fi
-
-	uname=$( uname -s )
-	if [[ $uname == @(Linux|GNU|GNU/*|FreeBSD|Cygwin|CYGWIN_*) ]]; then
-		manpath=$( manpath 2>/dev/null || command man --path )
-	else
-		manpath=$MANPATH
-	fi
-
-	if [ -z "$manpath" ]; then
-		COMPREPLY=( $( compgen -c -- $cur ) )
-		return 0
-	fi
-
-	# determine manual section to search
-	[[ "$prev" == $mansect ]] && sect=$prev || sect='*'
-
-	manpath=$manpath:
-	if [ -n "$cur" ]; then
-		manpath="${manpath//://*man$sect/$cur* } ${manpath//://*cat$sect/$cur* }"
-	else
-		manpath="${manpath//://*man$sect/ } ${manpath//://*cat$sect/ }"
-	fi
-
-	# redirect stderr for when path doesn't exist
-	COMPREPLY=( $( eval command ls "$manpath" 2>/dev/null ) )
-	# weed out directory path names and paths to man pages
-	COMPREPLY=( ${COMPREPLY[@]##*/?(:)} )
-	# strip suffix from man pages
-	COMPREPLY=( ${COMPREPLY[@]%.@(gz|bz2|lzma)} )
-	COMPREPLY=( $( compgen -W '${COMPREPLY[@]%.*}' -- "${cur//\\\\/}" ) )
-
-	if [[ "$prev" != $mansect ]]; then
-		# File based completion for the rest, prepending ./ if needed
-		# (man 1.6f needs that for man pages in current dir)
-		local start=${#COMPREPLY[@]}
-		_filedir $manext
-		for (( i=$start; i < ${#COMPREPLY[@]}; i++ )); do
-			[[ ${COMPREPLY[i]} == */* ]] || COMPREPLY[i]=./${COMPREPLY[i]}
-		done
-	fi
-
-	return 0
-}
-[ $USERLAND = GNU -o $UNAME = Darwin \
-  -o $UNAME = FreeBSD -o $UNAME = SunOS -o $UNAME = Cygwin \
-  -o $UNAME = OpenBSD ] && \
-complete -F _man $filenames man apropos whatis
-
 # renice(8) completion
 #
 _renice()
diff --git a/contrib/man b/contrib/man
new file mode 100644
index 0000000..81f491b
--- /dev/null
+++ b/contrib/man
@@ -0,0 +1,75 @@
+# man(1) completion
+#
+[ $USERLAND = GNU -o $UNAME = Darwin \
+  -o $UNAME = FreeBSD -o $UNAME = SunOS -o $UNAME = Cygwin \
+  -o $UNAME = OpenBSD ] &&
+_man()
+{
+	local cur prev sect manpath manext mansect uname
+
+	manext="@([0-9lnp]|[0-9][px]|man|3pm)?(.@(gz|bz2|lzma))"
+	mansect="@([0-9lnp]|[0-9][px]|3pm)"
+
+	COMPREPLY=()
+	cur=`_get_cword`
+	prev=${COMP_WORDS[COMP_CWORD-1]}
+	
+	if [[ "$prev" == -l ]]; then
+		_filedir $manext
+		return 0
+	fi
+
+	_expand || return 0
+
+	# file based completion if parameter contains /
+	if [[ "$cur" == */* ]]; then
+		_filedir $manext
+		return 0
+	fi
+
+	uname=$( uname -s )
+	if [[ $uname == @(Linux|GNU|GNU/*|FreeBSD|Cygwin|CYGWIN_*) ]]; then
+		manpath=$( manpath 2>/dev/null || command man --path )
+	else
+		manpath=$MANPATH
+	fi
+
+	if [ -z "$manpath" ]; then
+		COMPREPLY=( $( compgen -c -- $cur ) )
+		return 0
+	fi
+
+	# determine manual section to search
+	[[ "$prev" == $mansect ]] && sect=$prev || sect='*'
+
+	manpath=$manpath:
+	if [ -n "$cur" ]; then
+		manpath="${manpath//://*man$sect/$cur* } ${manpath//://*cat$sect/$cur* }"
+	else
+		manpath="${manpath//://*man$sect/ } ${manpath//://*cat$sect/ }"
+	fi
+
+	# redirect stderr for when path doesn't exist
+	COMPREPLY=( $( eval command ls "$manpath" 2>/dev/null ) )
+	# weed out directory path names and paths to man pages
+	COMPREPLY=( ${COMPREPLY[@]##*/?(:)} )
+	# strip suffix from man pages
+	COMPREPLY=( ${COMPREPLY[@]%.@(gz|bz2|lzma)} )
+	COMPREPLY=( $( compgen -W '${COMPREPLY[@]%.*}' -- "${cur//\\\\/}" ) )
+
+	if [[ "$prev" != $mansect ]]; then
+		# File based completion for the rest, prepending ./ if needed
+		# (man 1.6f needs that for man pages in current dir)
+		local start=${#COMPREPLY[@]}
+		_filedir $manext
+		for (( i=$start; i < ${#COMPREPLY[@]}; i++ )); do
+			[[ ${COMPREPLY[i]} == */* ]] || COMPREPLY[i]=./${COMPREPLY[i]}
+		done
+	fi
+
+	return 0
+}
+[ $USERLAND = GNU -o $UNAME = Darwin \
+  -o $UNAME = FreeBSD -o $UNAME = SunOS -o $UNAME = Cygwin \
+  -o $UNAME = OpenBSD ] && \
+complete -F _man $filenames man apropos whatis

-- 
bash-completion



More information about the Bash-completion-commits mailing list