bash (readline) completion

bash (readline) completion

Post by Richard Kilgo » Wed, 12 May 1999 04:00:00



Is there any way to specify what readline should complete to?

I would really like to switch to bash from tcsh, but I don't know
if I can live without my completion rules.  For example, in tcsh,
I can set a variable to a list of available Debian Linux package
names, and provide tcsh with a completion rule that tells it to
choose between these package names for completion when I type
something like:

   prompt% apt-get install <Tab>

And in the same completion rule, I can tell it how to complete
apt-get commands, like the word "install" in the command above.

As far as I've been able to discover, readline can only complete
to file/dir names, executable files in my path, variables, and a
few other sets of lists over which I have no control.  And even
for these, it seems I have to specify which list I want as I'm
typing the command, rather than being able to specify context
rules for bash to remember for me which list I want.

I welcome anyone's answer who considers her/himself at least at a
medium experience level using bash--whether the answer is
positive or negative.

   thanks,

   - rick

--

Electrical & Computer Engineering   |  http://lore.ece.utexas.edu/~rkilgore/
The University of Texas at Austin   |  (512) 471-8011

 
 
 

bash (readline) completion

Post by Paul D. Smi » Wed, 12 May 1999 04:00:00


%% Regarding bash (readline) completion;

  rk> Is there any way to specify what readline should complete to?

No, not without writing code to extend it.

You might look at zsh; I've never used it, as I'm happy with bash, but I
think you can make it complete just about anything, just about
anywhere.

  rk> As far as I've been able to discover, readline can only complete
  rk> to file/dir names, executable files in my path, variables, and a
  rk> few other sets of lists over which I have no control.  And even
  rk> for these, it seems I have to specify which list I want as I'm
  rk> typing the command, rather than being able to specify context
  rk> rules for bash to remember for me which list I want.

I'm not quite sure what you mean by the last sentence, but bash has
context-sensitive completion.  Any word starting with $ completes on the

hostnames; any word as the first word on the line completes on
executables; and everything else (IIRC) completes on
filenames/directories.

--
-------------------------------------------------------------------------------

 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist
-------------------------------------------------------------------------------
   These are my opinions---Nortel Networks takes no responsibility for them.

 
 
 

bash (readline) completion

Post by Chet Ram » Thu, 13 May 1999 04:00:00




>Is there any way to specify what readline should complete to?

No, not with the current version.

Quote:>I would really like to switch to bash from tcsh, but I don't know
>if I can live without my completion rules.

I am working on a simple programmable completion mechanism that
will be in the next version of bash.
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
( ``Discere est Dolere'' -- chet)


 
 
 

1. BASH readline: complete & possible-completions both bound to TAB?

I am trying to set up bash to do *both* tab completions AND show me
the possible completions at the command line.  Example:

        $ em<TAB>
        emacs          emacs19        emacsclient    emacsclient19  
        $ emacs

This behavior is equivalent to 'set autolist = beepnone' in tcsh.

Currently I can type:   $ em<TAB>
and I will get:         $ emacs

or I can type:          $ em<M-?>
and I will get:         emacs     emacs19    emacsclient   emacsclient19  
                        $ em

I have tried putting both 'possible-completions' and 'complete' inside
of .inputrc but it will only act upon the last one in the file.  So,

.inputrc:       TAB: possible-completions
                TAB: complete

only behaves as if 'complete' were entered.  I've tried a lot of other
combinations also, but since they didn't work either, I won't bore you
with them.  

Info (I don't think you'll need it):
        Version:        GNU bash, version 1.12.1
        System:         Ultrix on a DECsystem 5900
OR
        Version:        GNU bash, version 1.13.1-CWRU
        System:         SunOS Release 4.1.3C on a Sun

Any advice on how to get both 'possible-completions' and 'complete'
bound to TAB would be greatly appreciated.

Thanks,
Sam
(who checked the FAQ)

---------------------------------------------------
P.S.  Of course, I could always put in my .inputrc:

        TAB: complete
        ESC: possible-completions

and just press the ESC key when I want to see the possible
completions.  But in that case, I lose ESC as the meta prefix.  As an
aside, anyone know how to bind Meta to another key-sequence (like
C-[) and yet keep ESC bound to 'possible-completions' (or something
else)?
---------------------------------------------------

2. Stoping Boot PROM

3. BASH BASH BASH BASH BASH BASH BASH BASH BASH BASH

4. Awk usage help!

5. Setting up completion and possible completion in BASH

6. memorex-cdrw-6424

7. readline bashing (was POSIX bashing)

8. 0.99.14 (was Re: Found slow socket bug :))

9. POSIX bashing (readline bashing)

10. Ware Ware Wizardjin (was Re: readline bashing (was POSIX bashing))

11. Linux shell / readline: filename completion?

12. Readline or not Readline...

13. Problem with readline's clear-screen after installing bash 2.0