complete in Mac OS X

By: Strauss K Emailed: 1730 times Printed: 2344 times    

Latest comments
By: rohit kumar - how this program is work
By: Kirti - Hi..thx for the hadoop in
By: Spijker - I have altered the code a
By: ali mohammed - why we use the java in ne
By: ali mohammed - why we use the java in ne
By: mizhelle - when I exported the data
By: raul - no output as well, i'm ge
By: Rajesh - thanx very much...
By: Suindu De - Suppose we are executing

Edit command specific tab-completions.

Syntax
      complete [-abcdefgjksuv] [-o comp-option] [-A action] [-G globpat] [-W wordlist]
                  [-P prefix] [-S suffix] suffix] [-X filterpat] [-F function]
                     [-C command] name [name ...]

      complete -pr [name ...]

Specify how arguments to each name should be completed. If the -p option is supplied, or if no options are supplied, existing completion specifications are printed in a way that allows them to be reused as input. The -r option removes a completion specification for each name, or, if no names are supplied, all completion specifications.

Other options, if specified, have the following meanings. The arguments to the -G, -W, and -X options (and, if necessary, the -P and -S options) should be quoted to protect them from expansion before the complete builtin is invoked.

Key:
   -o comp-option
                 The comp-option controls several aspects of the compspec's behavior beyond the  simple
                 generation of completions.  comp-option may be one of:
                    bashdefault
                            Perform the rest of the default bash completions if the compspec generates no
                            matches.
                    default Use readline's default filename completion if the compspec generates no
                            matches.
                    dirnames
                            Perform directory name completion if the compspec generates no matches.
                    filenames
                            Tell  readline  that  the  compspec generates filenames, so it can perform any
                            filename-specific processing (like adding a slash to directory names or suppressing 
                            trailing spaces). Intended to be used with shell functions.
                    nospace Tell readline not to append a space (the default) to words completed at the
                            end of the line.
                    plusdirs
                            After any matches defined by the compspec are generated, directory name completion
                            is  attempted  and  any matches are added to the results of the other actions.

   -A action
                    The action may be one of the following to generate a list of possible completions:

                    alias    Alias names.  May also be specified as -a.
                    arrayvar Array variable names.
                    binding  Readline key binding names.
                    builtin  Names of shell builtin commands.  May also be specified as -b.
                    command  Command names.  May also be specified as -c.
                    directory  Directory names.  May also be specified as -d.
                    disabled   Names of disabled shell builtins.
                    enabled  Names of enabled shell builtins.
                    export   Names of exported shell variables.  May also be specified as -e.
                    file     File names.  May also be specified as -f.
                    function Names of shell functions.
                    group    Group names.  May also be specified as -g.
                    helptopic  Help topics as accepted by the help builtin.
                    hostname   Hostnames, as taken from the file specified by the HOSTFILE shell variable.
                    job      Job names, if job control is active.  May also be specified as -j.
                    keyword  Shell reserved words.  May also be specified as -k.
                    running  Names of running jobs, if job control is active.
                    service  Service names.  May also be specified as -s.
                    setopt   Valid arguments for the -o option to the set builtin.
                    shopt    Shell option names as accepted by the shopt builtin.
                    signal   Signal names.
                    stopped  Names of stopped jobs, if job control is active.
                    user     User names.  May also be specified as -u.
                    variable Names of all shell variables.  May also be specified as -v.

   -G globpat       The filename expansion pattern globpat is expanded to generate the possible completions.

   -W wordlist      The  wordlist is split using the characters in the IFS special variable as delimiters,
                    and each resultant word is expanded.  The possible completions are the members of the
                    resultant list which match the word being completed.

   -C command       command is executed in a subshell environment, and its output is used as the possible
                    completions.

   -F function      The shell function function is executed in the current shell environment. When it
                    finishes, the possible completions are retrieved from the value of the COMPREPLY array
                    variable.

   -X filterpat     filterpat is a pattern as used for filename expansion.  It is applied to the list of
                    possible  completions  generated by the preceding options and arguments, and each completion
                    matching filterpat is removed from the list.  A leading ! in filterpat negates
                    the pattern; in this case, any completion not matching filterpat is removed.

   -P prefix        prefix is added at the beginning of each possible completion after all other options
                    have been applied.

   -S suffix        suffix is appended to each possible completion after all other options have been
                    applied.

The return value is true unless an invalid option is supplied, an option other than -p or -ris supplied without a name argument, an attempt is made to remove a completion specification for a name for which no specification exists, or an error occurs adding a completion specification.

Standard bash Tab Completion:

Type part of a command (enough to uniquely identify the command) and press Tab once > completes the command. 
Type part of a command (not enough to uniquely identify the command) and press Tab twice > list of commands.

$ le[TAB]

Type a command + part of a file/folder name (enough to uniquely identify the file) and press Tab once > completes the file or folder name. 
Type a command + part of a file/folder name (not enough to uniquely identify the file) and press Tab twice > list of file/folder names.

$ less dem[TAB]

Type a command + part of a file name (enough to uniquely identify the file) and press Escape and / > completes the file name. 

$ less demo[ESC + /]

Example

Using complete for the executable SS64 to 1) show only files not directories and 2) exclude any files that don't have an extension .dem from the tab-completion:

$ complete -f -X '!*.dem' SS64
$ SS64[TAB]


macos Home | All macos Tutorials | Latest macos Tutorials

Sponsored Links

If this tutorial doesn't answer your question, or you have a specific question, just ask an expert here. Post your question to get a direct answer.



Bookmark and Share

Comments(0)


Be the first one to add a comment

Your name (required):


Your email(required, will not be shown to the public):


Your sites URL (optional):


Your comments:



More Tutorials by Strauss K
cut in Mac OS X
curl in Mac OS X
crontab in Mac OS X
cron in Mac OS X
cp in Mac OS X
continue in Mac OS X
complete in Mac OS X
command in Mac OS X
comm in Mac OS X
cmp in Mac OS X
cksum in Mac OS X
chroot in Mac OS X
chown in Mac OS X
chmod in Mac OS X
chgrp in Mac OS X

More Tutorials in macos
Getting PHP running on Mac OS 10.1
Installing gedit for python programming in Mac OS X
What is Mac OS X?
History of Mac OS X
Major features of Mac OS X
Different Versions of Mac OS X
What is new in Mac OS X Snow Leopard
alias, unalias in Mac OS X
apropos in Mac OS X
awk in Mac OS X
basename in Mac OS X
bash in Mac OS X
bg in Mac OS X
bless in Mac OS X
break in Mac OS X

More Latest News
Most Viewed Articles (in macos )
chmod in Mac OS X
complete in Mac OS X
crontab in Mac OS X
curl in Mac OS X
cp in Mac OS X
What is Mac OS X?
Major features of Mac OS X
Different Versions of Mac OS X
alias, unalias in Mac OS X
bless in Mac OS X
bzip in Mac OS X
cal, ncal in Mac OS X
caller in Mac OS X
cat in Mac OS X
chown in Mac OS X
Most Emailed Articles (in macos)
bless in Mac OS X
bash in Mac OS X
cal, ncal in Mac OS X
chroot in Mac OS X
What is Mac OS X?
History of Mac OS X
Major features of Mac OS X
Different Versions of Mac OS X
What is new in Mac OS X Snow Leopard
alias, unalias in Mac OS X
apropos in Mac OS X
awk in Mac OS X
basename in Mac OS X
bg in Mac OS X
break in Mac OS X