While running the complete
command on my gnome-terminal, it shows some commands.What are they? And what is the use of complete
command?
$ complete
complete -F _minimal
complete -F _filedir_xspec oodraw
complete -F _filedir_xspec elinks
complete -F _filedir_xspec freeamp
complete -F _longopt split
complete -F _longopt sed
complete -F _longopt ld
complete -F _longopt grep
complete -F _service /etc/init.d/vboxweb-service
complete -F _service /etc/init.d/vboxballoonctrl-service
complete -F _service /etc/init.d/rc
complete -F _service /etc/init.d/nmbd
complete -F _service /etc/init.d/halt
complete -j -P '"%' -S '"' jobs
complete -d pushd
List goes long, so i posted some of the them.
complete
is a bash builtin function. So there is not a binary on the system. It handles how commands will be completed when pressing tab.Example: if you type:
...a list is appearing with all possible values for this command. In this case it means all running processes. See the output of the
complete
function:This means that the function
_pgrep
(-F) is executed when tabbing the commandpidof
. The definition of this function is in/etc/bash_completion.d/procps
.Another example: if you type:
...you see the list of folders you can
cd
to under/usr/
. Which function is executed? greping thecomplete
function (as above) tells us it's the funtction_cd
in/etc/bash_completion
.Do it yourself: You have a program/script called
/bin/myprog
and you want that if you execute it as follows...it should only list folders, not files. So extend your bash completion with the following command:
That's it. You can also write own functions to complete custom things, for example complete only specific files or numbers or lists of static values...
complete
is a bash command used to perform the auto-complete action when the user hit the TAB key in a terminal.Calling just
complete
will list all the functions registered for auto-completion of commands or services options.From the bash man pages:
Check
/usr/share/bash-completion/bash_completion
to see the default completions that come with bash.Visit http://www.linuxjournal.com/content/more-using-bash-complete-command for a full tutorial about this command.