You are not logged in.

#1 2009-07-03 00:16:30

pooldoo
Member
Registered: 2008-06-07
Posts: 14

cd command completion confusion

Suppose i have a directory named documents and a file named doctors.  If I enter

$ cd doc<tab><tab>
documents/ doctors

If my memory is failing, I apologize, but in the past I thought the completion feature only would look for directories.  Has something changed?

Offline

#2 2009-07-03 01:53:32

Statix
Member
From: Hangzhou, China
Registered: 2008-02-16
Posts: 240

Re: cd command completion confusion

As long as I remember it it's done both files and folders. That's how it works on my system right now. It doesn't care what command it's started with (whether it be cd or cat, for example) so it shows all.

I imagine that you could get it to behave differently depending on command, but I've never looked into doing that.


Madly in love with Arch64, Openbox, DotA, and of course... penguins!
Happy to help if you're not a Help Vampire. Use your wonderful resources like ArchWiki, Google, and our wonderful search page.

Offline

#3 2009-07-03 01:58:53

Trent
Member
From: Baltimore, MD (US)
Registered: 2009-04-16
Posts: 990

Re: cd command completion confusion

Only completes folders here.  Do you have bash-completion installed?

Offline

#4 2009-07-03 02:05:11

Ranguvar
Member
Registered: 2008-08-12
Posts: 2,549

Re: cd command completion confusion

It depends on the command. With cd, completion should only match folders.

Offline

#5 2009-07-03 02:18:42

Statix
Member
From: Hangzhou, China
Registered: 2008-02-16
Posts: 240

Re: cd command completion confusion

Actually yeah you guys are right, haha. I didn't test it well enough I guess. cd seems to only match folders, but all other commands seem to do both.


Madly in love with Arch64, Openbox, DotA, and of course... penguins!
Happy to help if you're not a Help Vampire. Use your wonderful resources like ArchWiki, Google, and our wonderful search page.

Offline

#6 2009-07-03 02:38:08

crouse
Arch Linux f@h Team Member
From: Iowa - USA
Registered: 2006-08-19
Posts: 907
Website

Re: cd command completion confusion

I'd like to suggest:
http://wiki.archlinux.org/index.php/Bas … Completion

I think you'll find what your looking for there, in order to setup bash completion that is smart enough to know to find directories only.  smile

Offline

#7 2009-07-03 04:19:15

dmz
Member
From: Sweden
Registered: 2008-08-27
Posts: 881
Website

Re: cd command completion confusion

... or just use zsh. smile

Offline

#8 2009-07-03 04:21:15

crouse
Arch Linux f@h Team Member
From: Iowa - USA
Registered: 2006-08-19
Posts: 907
Website

Re: cd command completion confusion

or not tongue

Offline

#9 2009-07-03 05:19:01

pooldoo
Member
Registered: 2008-06-07
Posts: 14

Re: cd command completion confusion

Yes, I do have bash-completion installed.  And I read the wiki, but still don't understand.  It was working right until recenty, don't know what happened.  I'm tempted to try zsh, but I don't really want to change shells just because one command got a little funky.  Any other ideas?

Offline

#10 2009-07-03 15:52:41

arkham
Member
From: Stockholm
Registered: 2008-10-26
Posts: 516
Website

Re: cd command completion confusion

Reinstall bash and post (if they exist) your ~/.bashrc, ~/.bash_profile and ~/.profile


"I'm Winston Wolfe. I solve problems."

~ Need moar games? [arch-games] ~ [aurcheck] AUR haz updates? ~

Offline

#11 2009-07-03 20:05:59

pooldoo
Member
Registered: 2008-06-07
Posts: 14

Re: cd command completion confusion

I reinstalled bash but the problem persists.

#.bashrc
alias ls='ls --color=auto'
PS1='[\u@\h \W]\$ '
alias dir='ls -d */'
alias move='mv -i'
PATH=$PATH:/home/d/bin
# bash_profile

$HOME/.bashrc
startx

Is there a configuration file for determining rules for completion?  I can't imagine what I may have done to change this, other than updating my system.  It seems odd that others aren't having this problem.

Offline

#12 2009-07-03 21:04:12

droog
Member
Registered: 2004-11-18
Posts: 877

Re: cd command completion confusion

pooldoo wrote:

Is there a configuration file for determining rules for completion?  I can't imagine what I may have done to change this, other than updating my system.  It seems odd that others aren't having this problem.

Seems you still need this in your .bashrc, at least i do.

if [ -f /etc/bash_completion ]; then
      . /etc/bash_completion
fi

Offline

#13 2009-07-04 12:12:11

pooldoo
Member
Registered: 2008-06-07
Posts: 14

Re: cd command completion confusion

That worked!  Thanks a lot droog, and everyone else.

Looking at my archived .bashrc from before the completion problem occurred, I see that the missing line of code wasn't there. Maybe bash_completion was previously started elsewhere on my system?  So it's a mystery to me how this occurred, but all's well now.

Offline

#14 2009-08-30 04:49:34

lolilolicon
Member
Registered: 2009-03-05
Posts: 1,722

Re: cd command completion confusion

First, sorry for bringing this old thread back...well,

As for the reason why bash_completion ain't sourced as described in the wiki, it is because your terminal is not a login shell. Check /etc/profile.d/bash_completion.sh and you will see.

Do as droog suggested. Works totally fine. big_smile

Last edited by lolilolicon (2009-08-30 04:50:23)


This silver ladybug at line 28...

Offline

#15 2009-08-30 10:23:40

Profjim
Member
From: NYC
Registered: 2008-03-24
Posts: 658

Re: cd command completion confusion

Yeah, I had posted a bug report about this back in the days when we had a bug tracker. /etc/profile.d/bash_completion is deciding whether to automatically call /etc/bash_completion for you. They used to decide based on the non-emptiness of "$PS1", which would include all interactive shells; now they decide based on "shopt -q login_shell" which only includes login shells. I don't think this change is justified, but...

Offline

Board footer

Powered by FluxBB