[Bash-completion-commits] [SCM] bash-completion branch, master, updated. 1bfaacd1a0a79b26b682ed8676341ee88f4ee92d
Guillaume Rousse
guillomovitch at zarb.org
Wed May 20 23:42:45 UTC 2009
The following commit has been merged in the master branch:
commit a8a1529bfe5a453af69954718454b11eb0daa5e2
Author: Guillaume Rousse <guillomovitch at zarb.org>
Date: Thu May 21 01:40:30 2009 +0200
split find completion
diff --git a/Makefile.am b/Makefile.am
index 549a787..84bbaa1 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -19,6 +19,7 @@ bashcomp_DATA = contrib/ant \
contrib/dd \
contrib/dhclient \
contrib/dsniff \
+ contrib/findutils \
contrib/freeciv \
contrib/gcl \
contrib/gdb \
diff --git a/bash_completion b/bash_completion
index eeeb31a..3420a70 100644
--- a/bash_completion
+++ b/bash_completion
@@ -1169,119 +1169,6 @@ have pgrep && complete -F _pgrep pgrep
# Linux pidof(8) completion.
[ $UNAME = Linux ] && complete -F _pgrep pidof
-# GNU find(1) completion. This makes heavy use of ksh style extended
-# globs and contains Linux specific code for completing the parameter
-# to the -fstype option.
-#
-_find()
-{
- local cur prev i exprfound onlyonce
-
- COMPREPLY=()
- cur=`_get_cword`
- prev=${COMP_WORDS[COMP_CWORD-1]}
-
- case "$prev" in
- -@(max|min)depth)
- COMPREPLY=( $( compgen -W '0 1 2 3 4 5 6 7 8 9' -- $cur ) )
- return 0
- ;;
- -?(a|c)newer|-fls|-fprint?(0|f)|-?(i)?(l)name|-?(i)wholename)
- _filedir
- return 0
- ;;
- -fstype)
- # this is highly non-portable
- [ -e /proc/filesystems ] &&
- COMPREPLY=( $( compgen -W "$( cut -d$'\t' -f2 /proc/filesystems )" -- $cur ) )
- return 0
- ;;
- -gid)
- _gids
- return 0
- ;;
- -group)
- if [ -n "$bash205" ]; then
- COMPREPLY=( $( compgen -g -- $cur 2>/dev/null) )
- fi
- return 0
- ;;
- -?(x)type)
- COMPREPLY=( $( compgen -W 'b c d p f l s' -- $cur ) )
- return 0
- ;;
- -uid)
- _uids
- return 0
- ;;
- -user)
- COMPREPLY=( $( compgen -u -- $cur ) )
- return 0
- ;;
- -exec|-ok)
- COMP_WORDS=(COMP_WORDS[0] $cur)
- COMP_CWORD=1
- _command
- return 0
- ;;
- -[acm]min|-[acm]time|-?(i)?(l)?(whole)name|-inum|-?(i)path|-?(i)regex| \
- -links|-perm|-size|-used|-printf)
- # do nothing, just wait for a parameter to be given
- return 0
- ;;
- esac
-
- _expand || return 0
-
- # set exprfound to 1 if there is already an expression present
- for i in ${COMP_WORDS[@]}; do
- [[ "$i" = [-\(\),\!]* ]] && exprfound=1 && break
- done
-
- # handle case where first parameter is not a dash option
- if [ "$exprfound" != 1 ] && [[ "$cur" != [-\(\),\!]* ]]; then
- _filedir -d
- return 0
- fi
-
- # complete using basic options
- COMPREPLY=( $( compgen -W '-daystart -depth -follow -help -maxdepth \
- -mindepth -mount -noleaf -version -xdev -amin -anewer \
- -atime -cmin -cnewer -ctime -empty -false -fstype \
- -gid -group -ilname -iname -inum -ipath -iregex \
- -wholename \
- -links -lname -mmin -mtime -name -newer -nouser \
- -nogroup -perm -regex -size -true -type -uid -used \
- -user -xtype -exec -fls -fprint -fprint0 -fprintf -ok \
- -print -print0 -printf -prune -ls -wholename -iwholename' -- $cur ) )
-
- # this removes any options from the list of completions that have
- # already been specified somewhere on the command line, as long as
- # these options can only be used once (in a word, "options", in
- # opposition to "tests" and "actions", as in the find(1) manpage).
- onlyonce=' -daystart -depth -follow -help -maxdepth -mindepth -mount \
- -noleaf -version -xdev '
- COMPREPLY=( $( echo "${COMP_WORDS[@]}" | \
- (while read -d ' ' i; do
- [ "$i" == "" ] ||
- [ "${onlyonce/ ${i%% *} / }" == "$onlyonce" ] &&
- continue
- # flatten array with spaces on either side,
- # otherwise we cannot grep on word boundaries of
- # first and last word
- COMPREPLY=" ${COMPREPLY[@]} "
- # remove word from list of completions
- COMPREPLY=( ${COMPREPLY/ ${i%% *} / } )
- done
- echo "${COMPREPLY[@]}")
- ) )
-
- _filedir
-
- return 0
-}
-complete -F _find $filenames find
-
# Linux iwconfig(8) completion
#
[ $UNAME = Linux ] && have iwconfig &&
diff --git a/contrib/findutils b/contrib/findutils
new file mode 100644
index 0000000..819e61a
--- /dev/null
+++ b/contrib/findutils
@@ -0,0 +1,115 @@
+# -*- mode: shell-script; sh-basic-offset: 8; indent-tabs-mode: t -*-
+# ex: ts=8 sw=8 noet filetype=sh
+#
+# bash completion for GNU find. This makes heavy use of ksh style extended
+# globs and contains Linux specific code for completing the parameter
+# to the -fstype option.
+
+_find()
+{
+ local cur prev i exprfound onlyonce
+
+ COMPREPLY=()
+ cur=`_get_cword`
+ prev=${COMP_WORDS[COMP_CWORD-1]}
+
+ case "$prev" in
+ -@(max|min)depth)
+ COMPREPLY=( $( compgen -W '0 1 2 3 4 5 6 7 8 9' -- $cur ) )
+ return 0
+ ;;
+ -?(a|c)newer|-fls|-fprint?(0|f)|-?(i)?(l)name|-?(i)wholename)
+ _filedir
+ return 0
+ ;;
+ -fstype)
+ # this is highly non-portable
+ [ -e /proc/filesystems ] &&
+ COMPREPLY=( $( compgen -W "$( cut -d$'\t' -f2 /proc/filesystems )" -- $cur ) )
+ return 0
+ ;;
+ -gid)
+ _gids
+ return 0
+ ;;
+ -group)
+ if [ -n "$bash205" ]; then
+ COMPREPLY=( $( compgen -g -- $cur 2>/dev/null) )
+ fi
+ return 0
+ ;;
+ -?(x)type)
+ COMPREPLY=( $( compgen -W 'b c d p f l s' -- $cur ) )
+ return 0
+ ;;
+ -uid)
+ _uids
+ return 0
+ ;;
+ -user)
+ COMPREPLY=( $( compgen -u -- $cur ) )
+ return 0
+ ;;
+ -exec|-ok)
+ COMP_WORDS=(COMP_WORDS[0] $cur)
+ COMP_CWORD=1
+ _command
+ return 0
+ ;;
+ -[acm]min|-[acm]time|-?(i)?(l)?(whole)name|-inum|-?(i)path|-?(i)regex| \
+ -links|-perm|-size|-used|-printf)
+ # do nothing, just wait for a parameter to be given
+ return 0
+ ;;
+ esac
+
+ _expand || return 0
+
+ # set exprfound to 1 if there is already an expression present
+ for i in ${COMP_WORDS[@]}; do
+ [[ "$i" = [-\(\),\!]* ]] && exprfound=1 && break
+ done
+
+ # handle case where first parameter is not a dash option
+ if [ "$exprfound" != 1 ] && [[ "$cur" != [-\(\),\!]* ]]; then
+ _filedir -d
+ return 0
+ fi
+
+ # complete using basic options
+ COMPREPLY=( $( compgen -W '-daystart -depth -follow -help -maxdepth \
+ -mindepth -mount -noleaf -version -xdev -amin -anewer \
+ -atime -cmin -cnewer -ctime -empty -false -fstype \
+ -gid -group -ilname -iname -inum -ipath -iregex \
+ -wholename \
+ -links -lname -mmin -mtime -name -newer -nouser \
+ -nogroup -perm -regex -size -true -type -uid -used \
+ -user -xtype -exec -fls -fprint -fprint0 -fprintf -ok \
+ -print -print0 -printf -prune -ls -wholename -iwholename' -- $cur ) )
+
+ # this removes any options from the list of completions that have
+ # already been specified somewhere on the command line, as long as
+ # these options can only be used once (in a word, "options", in
+ # opposition to "tests" and "actions", as in the find(1) manpage).
+ onlyonce=' -daystart -depth -follow -help -maxdepth -mindepth -mount \
+ -noleaf -version -xdev '
+ COMPREPLY=( $( echo "${COMP_WORDS[@]}" | \
+ (while read -d ' ' i; do
+ [ "$i" == "" ] ||
+ [ "${onlyonce/ ${i%% *} / }" == "$onlyonce" ] &&
+ continue
+ # flatten array with spaces on either side,
+ # otherwise we cannot grep on word boundaries of
+ # first and last word
+ COMPREPLY=" ${COMPREPLY[@]} "
+ # remove word from list of completions
+ COMPREPLY=( ${COMPREPLY/ ${i%% *} / } )
+ done
+ echo "${COMPREPLY[@]}")
+ ) )
+
+ _filedir
+
+ return 0
+}
+complete -F _find $filenames find
--
bash-completion
More information about the Bash-completion-commits
mailing list