path completion with cd - similar to tcsh

2011-04-14 Thread Peter Toft

Hi all

I have been using tcsh for a long time on Red Hat Linux boxes, and
bash on other UNIX-boxes. One thing I really love with tcsh is the way
I can swiftly operate using the  to do auto-complete, when having
a deep directory hierarchy. I have that...

With bash I surely could use your skills to improve my usage of bash
(read; allow me to ditch tcsh fully).

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

"cd $HOME" 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" expanded to "cd /home/pto/" (without the quotes) so I 
could
continue to press  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.

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.

That cited link is suggesting; "ESC ctrl-e gets rid of the
backslash, and if you want to keep the $VAR as $VAR, backspace over
the terminal space and continue. Or you can ESC ctrl-e again, and
convert the $VAR to its value, so you won't need to repeat the single
ESC ctrl-e for each further ."
which IMHO is not really what I want.

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

Best

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



Re: path completion with cd - similar to tcsh

2011-04-15 Thread Peter Toft

On Fri, 15 Apr 2011 15:07:16 +0800, Clark J. Wang wrote:

On Fri, Apr 15, 2011 at 6:19 AM, Peter Toft  wrote:


Hi all

I have been using tcsh for a long time on Red Hat Linux boxes, and
bash on other UNIX-boxes. One thing I really love with tcsh is the 
way
I can swiftly operate using the  to do auto-complete, when 
having

a deep directory hierarchy. I have that...

With bash I surely could use your skills to improve my usage of bash
(read; allow me to ditch tcsh fully).

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

"cd $HOME" 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" expanded to "cd /home/pto/" (without the quotes) so 
I could
continue to press  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.

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.

That cited link is suggesting; "ESC ctrl-e gets rid of the
backslash, and if you want to keep the $VAR as $VAR, backspace over
the terminal space and continue. Or you can ESC ctrl-e again, and
convert the $VAR to its value, so you won't need to repeat the 
single

ESC ctrl-e for each further ."
which IMHO is not really what I want.

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

Best

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



That also annoys me much. Try like this:

$ complete -o default -o nospace -d cd
$ cd $VAR/



well - with this I have to add the slash before the $VAR is expanded.
So - not quite there yet[1].

Best

Peter [1] who is lazy :)

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



Re: path completion with cd - similar to tcsh

2011-04-18 Thread Peter Toft

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" 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" expanded to "cd /home/pto/" (without the quotes) so 
I could
continue to press  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.


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
shows "$HOME", which is nice, but I prefer the expanding, and
$ cd $HOME/
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 ... "?


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