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: Peter Toft
Subject: Re: path completion with cd <tab> - similar to tcsh
Date: Tue, 19 Apr 2011 08:06:40 +0200
User-agent: Roundcube Webmail/0.5

On Mon, 18 Apr 2011 20:12:24 -0400, Chet Ramey wrote:
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.)

Right! bash --version gives -> 3.2.25(1)-release (x86_64-redhat-linux-gnu)

RH5.6 is not cutting edge (but I need it for tools-reasons), but I also dislike the current working method on e.g. Ubuntu 10.10, so I really like to get into the dirt on this one :)

$ complete -p cd
bash: complete: cd: no completion specification



"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.

oki, but "complete -o bashdefault -o nospace cd" will give me tab complete
on the possible environment variables, e.g.
$ cd $HOME<tab>
shows "$HOME", which is nice, but I prefer the expanding, and
$ cd $HOME/<tab>
does nothing (with the -o bashdefault)


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.

That would be really nice, hints to do so would be very welcomed!


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

Thanx Chet for your efforts.

BTW; Anyone who has the february emails from this list;
"I am guestimating, that you have discussed this in February
 (cf. http://www.gossamer-threads.com/lists/gentoo/user/227574)
 but the February archive seems to be lost;
 http://lists.gnu.org/archive/html/bug-bash/2011-02/msg00274.html
 so I cannot get the details of it."
Anyone who can forward the february-emails?

Best

Peter

--
Peter Toft, PhD
http://petertoft.dk



reply via email to

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