Shell tab-completion and other helpful command-line tricks

Jonas Norlander jonorland at gmail.com
Sat Jan 24 09:11:13 UTC 2009


2009/1/24 Nils Kassube <kassube at gmx.net>:
> Paul Rumelhart wrote:
>> One of the best time savers when in a bash shell is it's feature called
>> "tab completion".
>
> Indeed.
>
>> Some examples:
>>
>> Filenames:
>
> There are two things you didn't mention.
>
> 1. If a file name contains special characters the command completion uses
> backslashes as escape character in front of the special characters. E.g.
> if you have a file name "isn't this funny?.txt" and you type
>
> ls is<tab>
>
> the result of the command completion is this:
>
> ls isn\'t\ this\ funny\?.txt
>
> 2. The command completion doesn't work within quotes. Using the file name
> above it wouldn't work if I type this:
>
> ls "is<tab>
>
> So if you want to use command completion, don't use quotes.
>
>> Command-line switches - if you forget which switches ("--something") a
>> particular command takes, you can type the command followed by a space
>> and "--" and then press the tab key twice to get a list of possible
>> choices (for example "ls --<tab><tab>" will show you all of the
>> switches that ls will accept.
>
> Did you try that? It doesn't work here. Or is there some special addon to
> bash needed to make it work? If you don't know the switches, use
> the --help option. Many commands answer with a usage message.

Works for me.

>> There are lots of others I keep finding.  Many commands that have a
>> choice of arguments work to some degree.  For example, typing "alias
>> <tab><tab>" will show you which aliases you have currently defined.
>
> Doesn't work either. But if you want to get a list of your aliases just
> try the alias command without parameters.
>

Works for me.

~$ bash --version
GNU bash, version 3.2.39(1)-release (x86_64-pc-linux-gnu)
On Kubuntu Intrepid

/ Jonas




More information about the kubuntu-users mailing list