[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Tab Tab program/command line editing



debian-user-digest-request@lists.debian.org wrote:
> If you hit the tab key twice in a row it lists all available commands.

Try typing part of a command, then pressing <tab> once (without any
spaces).  For example:

  $ apro<tab>

The shell (Bash) will attempt word completion.  (In the above example,
my system completes the word 'apropos'.)  This is far better
demonstrated (by trying it) than explained, but here goes:

When the completion command (usually bound to the <tab> key) is invoked,
the shell will attempt to finish the word you have started typing.  If
it's the first word on a line, bash assumes you're typing a command and
will search for a command in your PATH (or the specified directory, if
you've got a directory preceding the command).  If it's not the first
word, bash assumes you want an argument for your command and matches
against filenames in your current directory (usually, see the man page
for details).

If it finds a single match (for a command or filename), it finishes off
the word and puts a space, ready for another argument.  If it finds more
than one match, it completes the word as far as possible (with letters
common to all matches) then stops, beeps, and waits for you to type some
more.  If you pressed <tab> as the first key on the command line, you
will prompt it to search for *all* available commands in your path (or
files in the current directory), which (usually) have no letters in
common, so it beeps straight away.

If, after partial completion and a beep, you type another <tab>, the
shell will assume you don't quite know what word you want and list out
all the available ones (commands or filenames).  If this is more than a
certain number, usually 100, it will prompt you first before spewing a
heap of alternatives at you.

With a little practice, command completion can quickly become your
friend.  You can get more information on the bash manpage (if your pager
can search, try searching for Completing), but it's far more intuitive
than a dry explanation can put across.  Just try it out.

-- 
Regards,
Ben Finney, System Administrator
PrintSoft Pty Ltd


Reply to: