bug-bash
[Top][All Lists]
Advanced

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

Re: path completion with cd <tab> - similar to tcsh


From: Chet Ramey
Subject: Re: path completion with cd <tab> - similar to tcsh
Date: Mon, 18 Apr 2011 20:12:24 -0400
User-agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.14) Gecko/20110221 Lightning/1.0b2 Thunderbird/3.1.8

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    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]