Bash-4.3 distribution sources and documentation
[platform/upstream/bash.git] / examples / complete / complete-examples
index 3b28dd2..8a0746d 100644 (file)
@@ -1,6 +1,23 @@
 #
 # Completion examples
 #
+#  Chet Ramey <chet.ramey@case.edu>
+#
+#  Copyright 2002 Chester Ramey
+#
+#   This program is free software; you can redistribute it and/or modify
+#   it under the terms of the GNU General Public License as published by
+#   the Free Software Foundation; either version 2, or (at your option)
+#   any later version.
+#
+#   TThis program is distributed in the hope that it will be useful,
+#   but WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#   GNU General Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License
+#   along with this program; if not, write to the Free Software Foundation,
+#   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
 #
 # This encapsulates the default bash completion code
@@ -162,11 +179,11 @@ _declare_func()
 
        COMPREPLY=()
        if (( $COMP_CWORD <= 1 )) || [[ $cur == '-' ]]; then
-               COMPREPLY=(-a -f -F -i -r -x -p)
+               COMPREPLY=(-a -f -F -i -p -r -t -x)
                return 0;
        fi
        if [[ $cur == '+' ]]; then
-               COMPREPLY=(+i +x)
+               COMPREPLY=(+i +t +x)
                return 0;
        fi
        if [[ $prev == '-p' ]]; then
@@ -252,7 +269,7 @@ _hash_func()
        prev=${COMP_WORDS[COMP_CWORD-1]}
 
        if (( $COMP_CWORD <= 1 )) || [[ $cur == '-' ]]; then
-               COMPREPLY=(-p -r)
+               COMPREPLY=(-p -r -t)
                return 0;
        fi
 
@@ -344,16 +361,16 @@ _complete_meta_func()
 
        if (( $COMP_CWORD <= 1 )) || [[ "$cur" == '-' ]]; then
                case "$cmd" in
-               complete) COMPREPLY=(-a -b -c -d -e -f -j -k -v -u -r -p -A -G -W -P -S -X -F -C);;
-               compgen)  COMPREPLY=(-a -b -c -d -e -f -j -k -v -u -A -G -W -P -S -X -F -C);;
+               complete) COMPREPLY=(-a -b -c -d -e -f -j -k -s -v -u -r -p -A -G -W -P -S -X -F -C);;
+               compgen)  COMPREPLY=(-a -b -c -d -e -f -j -k -s -v -u -A -G -W -P -S -X -F -C);;
                esac
                return 0
        fi
 
        if [[ $prev == -A ]]; then
                COMPREPLY=(alias arrayvar binding builtin command directory \
-disabled enabled export file function helptopic hostname job keyword \
-running setopt shopt signal stopped variable)
+disabled enabled export file 'function' helptopic hostname job keyword \
+running service setopt shopt signal stopped variable)
                return 0
        elif [[ $prev == -F ]]; then
                COMPREPLY=( $( compgen -A function $cur ) )
@@ -400,7 +417,11 @@ _make_targets ()
        esac
 
        # make reads `makefile' before `Makefile'
-       if [ -f makefile ]; then
+       # GNU make reads `GNUmakefile' before all other makefiles, but we
+       # check that we're completing `gmake' before checking for it
+       if [ -f GNUmakefile ] && [ ${COMP_WORDS[0]} == gmake ]; then
+               mdef=GNUmakefile
+       elif [ -f makefile ]; then
                mdef=makefile
        elif [ -f Makefile ]; then
                mdef=Makefile
@@ -458,11 +479,13 @@ complete -d mkdir rmdir
 complete -f strip
 
 complete -f -X '*.gz' gzip
+complete -f -X '*.bz2' bzip2
 complete -f -X '*.Z' compress
 complete -f -X '!*.+(gz|tgz|Gz)' gunzip gzcat zcat zmore
 complete -f -X '!*.Z' uncompress zmore zcat
-
-complete -f -X '!*.+(gif|jpg|jpeg|GIF|JPG|bmp)' xv
+complete -f -X '!*.bz2' bunzip2 bzcat
+complete -f -X '!*.zip' unzip
+complete -f -X '!*.+(gif|jpg|jpeg|GIF|JPG|JPEG|bmp)' xv
 
 complete -f -X '!*.pl' perl perl5
 
@@ -470,13 +493,17 @@ complete -A hostname rsh telnet rlogin ftp ping xping host traceroute nslookup
 complete -A hostname rxterm rxterm3 rxvt2
 
 complete -u su
+complete -g newgrp groupdel groupmod
 
 complete -f -X '!*.+(ps|PS)' gs gv ghostview psselect pswrap
-complete -f -X '!*.+(dvi|DVI)' dvips xdvi dviselect dvitype
-complete -f -X '!*.+(pdf|PDF)' acroread
+complete -f -X '!*.+(dvi|DVI)' dvips xdvi dviselect dvitype catdvi
+complete -f -X '!*.+(pdf|PDF)' acroread4
 complete -f -X '!*.texi*' makeinfo texi2dvi texi2html
 complete -f -X '!*.+(tex|TEX)' tex latex slitex
 
+complete -f -X '!*.+(mp3|MP3)' mpg123
+complete -f -X '!*.+(htm|html)' links w3m lynx
+
 #
 # other possibilities, left as exercises
 #