On 4/14/11 6:19 PM, Peter Toft wrote:

> I have an annoying bash-problem on Red Hat Linux 5.x. If I e.g. try to move
> to a subdirectory of another directory (e.g. $HOME), where the tab-expand
> works poorly;
> 
> Assume $HOME=/home/pto

You should see whether or not you have a completion already defined by
running `complete -p cd'.  It would also help to know the version of bash
you're using.  That will help establish a baseline.  (And RHL 5.x?  That's
pretty old.)

> "cd $HOME<TAB>" is expanded to "cd /home/pto " (without the quotes).
> I get $HOME expanded - quite ok - but I get an annoying space efter the path.
> I will never like that space, I strongly prefer if I could get
> "cd $HOME<TAB>" expanded to "cd /home/pto/" (without the quotes) so I could
> continue to press <TAB> and see the allowed sub-directories - much faster
> for me.
> 
> I have also understood I can do
> $ complete -o nospace  cd
> to change the mode of operation, but this seems to disable the auto-complete
> function when doing cd $VARIABLE<TAB>.

You need to add -o bashdefault to restore the bash default completions,
which include shell variable completion.

> Any hints on this? Can I set the mode of operation as I like where the
> infamous space is replaced by a slash when doing "cd ... <TAB>"?

Right now, you cannot do this using only the built-in bash completion
mechanisms.  The best you can do is to suppress the space.  You can write
a function to do this, though, and bind it using complete -F funcname cd.

You can't prevent the `$' from being backslash-quoted and still quote
other filenames containing shell meta-characters unless you use a
shell function.

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    c...@case.edu    http://cnswww.cns.cwru.edu/~chet/

Reply via email to