question regarding CLI Tab-search

cbbrowne-HInyCGIudOg at public.gmane.org cbbrowne-HInyCGIudOg at public.gmane.org
Wed Dec 29 21:42:04 UTC 2004


> Matt Cahill wrote:
> > Hello,
> > 
> >   So, to my amazement, somebody finally revealed to me that I can find the 
> > names of files on my system by entering the first digits and then hitting T
ab 
> > twice (using an xconsole at least).  What is the name of this feature?  I'd
 
> > love to read up more about it (for example, why I can find apps as root but
 
> > not as user and how I would change such settings) before I post questions 
> > here.  I'm a little surprised that I wasn't aware of it before now...
> 
> Tab completion.  Also, it depends on the shell you use.  Bash has it, 
> some others don't.

This is sometimes termed "globbing", but is more properly termed
"expansion."

The shell where it was particularly popularized was the Tenex C shell;
in that case, it involved expanding two things:
 a) Command names, and
 b) File names.

zsh and Bash have since "been at war" to add additional features, with
zsh being the more aggressive in the fashion.

With the latest versions, zsh supports building scripts to complete all
sorts of command line parameters, often in a strongly-typed fashion.

For instance, if I type "ssh -" and hit [tab], it will show the
following:

cbbrowne at dba2:~> ssh -                                       Wednesday
16:37:42
-1  -- forces ssh to try protocol version 1 only
-2  -- forces ssh to try protocol version 2 only
-4  -- forces ssh to use IPv4 addresses only
-6  -- forces ssh to use IPv6 addresses only
-A  -- enables forwarding of the authentication agent connection
-C  -- compress data
-D  -- specify a dynamic port forwarding
-F  -- specify alternate config file
-I  -- specify smartcard device
-L  -- specify local port forwarding
-N  -- do not execute a remote command. (protocol version 2 only)
-P  -- use non privileged port
-R  -- specify remote port forwarding
-T  -- disable pseudo-tty allocation (protocol version 2 only)
-V  -- show version number
-X  -- enable X11 forwarding
-a  -- disable forwarding of authentication agent connection
-b  -- specify interface to transmit on
-c  -- select encryption cipher
-e  -- set escape character
-f  -- go to background
-g  -- allow remote hosts to connect to local forwarded ports
-i  -- select identity file
-k  -- disable forwarding of kerberos tickets
-l  -- specify login name
-m  -- specify mac algorithms
-n  -- redirect stdin from /dev/null
-o  -- specify extra options
-p  -- specify port on remote host
-q  -- quiet operation
-s  -- invoke subsystem
-t  -- force pseudo-tty allocation
-v  -- verbose mode
-x  -- disable X11 forwarding

Extend that a bit:

% ssh -c [TAB]
3des      arcfour   blowfish  des       idea      none      tss

I could thus specify blowfish encryption by typing:
% ssh -c b[TAB]

Scripting up a suitable set of functions to provide smart parameter
completion does take some effort, but if you check out a zsh install,
you'll find that this has been done for hundreds of more-or-less popular
commands.
--
select 'cbbrowne' || '@' || 'gmail.com';
http://linuxfinances.info/info/unix.html
Signs of a Klingon Programmer - 3. "This  machine is GAGH! I need dual
Pentium processors if I am to do battle with this code!"
--
The Toronto Linux Users Group.      Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml





More information about the Legacy mailing list