Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Bash completion for directories
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
nelsooon
n00b
n00b


Joined: 08 Aug 2004
Posts: 62

PostPosted: Mon Jul 01, 2013 2:49 pm    Post subject: Bash completion for directories Reply with quote

Hello all,

I am using guake terminal.
Is there a way to perform a bash completion for folders when doing a "cd [tab]".
Actually it prints all files that are present in the pointed directory.

I've already :
- put bash-completion in USE flags of /etc/make.conf
- emerged bash-completion and gentoo-bashcomp
- eselect bashcomp enable gentoo (and even all completion possibilities by doing : for i in $(ls --color=no /usr/share/bash-completion/); do ln -s /usr/share/bash-completion/$i /etc/bash_completion.d/$i; done)
- and source /etc/bash/bashrc

Thank you for your help
nelson
Back to top
View user's profile Send private message
labo
n00b
n00b


Joined: 29 Jul 2013
Posts: 1

PostPosted: Mon Jul 29, 2013 10:04 am    Post subject: Reply with quote

Have you tried the following?
Code:
eselect bashcomp enable [--global] base
source /etc/profile
Back to top
View user's profile Send private message
pjp
Administrator
Administrator


Joined: 16 Apr 2002
Posts: 16102
Location: Colorado

PostPosted: Mon Jul 29, 2013 4:00 pm    Post subject: Reply with quote

Moved from Documentation, Tips & Tricks to Off the Wall.
_________________
lolgov. 'cause where we're going, you don't have civil liberties.

In Loving Memory
1787 - 2008
Back to top
View user's profile Send private message
Naib
Advocate
Advocate


Joined: 21 May 2004
Posts: 4103
Location: Removed by Neddy

PostPosted: Mon Jul 29, 2013 4:12 pm    Post subject: Reply with quote

shouldn't this be other things gentoo since it is gentoo related?
_________________
A free press is the unsleeping guardian of every other right that free men prize; it is the most dangerous foe of tyranny. Where men have the habit of liberty, the Press will continue to be the vigilant guardian of the rights of the ordinary citizen.
Back to top
View user's profile Send private message
Bigun
Veteran
Veteran


Joined: 21 Sep 2003
Posts: 1959

PostPosted: Mon Jul 29, 2013 5:04 pm    Post subject: Reply with quote

Naib wrote:
shouldn't this be other things gentoo since it is gentoo related?


++

All this will add is unnecessary dick jokes.
Back to top
View user's profile Send private message
GabrielYYZ
n00b
n00b


Joined: 03 May 2012
Posts: 17
Location: Dominican Republic

PostPosted: Tue Jul 30, 2013 12:27 am    Post subject: Reply with quote

Bigun wrote:
Naib wrote:
shouldn't this be other things gentoo since it is gentoo related?


++

All this will add is unnecessary dick jokes.


In the context of this thread, they might be inappropriate, but there is no such thing as an unnecessary dick joke. :lol:
Back to top
View user's profile Send private message
Bones McCracker
Veteran
Veteran


Joined: 14 Mar 2006
Posts: 1563
Location: U.S.A.

PostPosted: Tue Jul 30, 2013 1:06 am    Post subject: Reply with quote

There's no way that I know of, but is it really too hard to type the first letter or two of the directory name before pressing tab? I mean, just how lazy do you want to be? :lol:
_________________
True Liberals are individualists. Democrats, on the other hand, are authoritarian collectivists.
Back to top
View user's profile Send private message
pjp
Administrator
Administrator


Joined: 16 Apr 2002
Posts: 16102
Location: Colorado

PostPosted: Tue Jul 30, 2013 2:54 am    Post subject: Reply with quote

Moved from Off the Wall to Other Things Gentoo.

Didn't notice the Gentoo reference earlier.
_________________
lolgov. 'cause where we're going, you don't have civil liberties.

In Loving Memory
1787 - 2008
Back to top
View user's profile Send private message
dmpogo
Advocate
Advocate


Joined: 02 Sep 2004
Posts: 2277
Location: Canada

PostPosted: Tue Jul 30, 2013 2:59 am    Post subject: Reply with quote

BoneKracker wrote:
There's no way that I know of, but is it really too hard to type the first letter or two of the directory name before pressing tab? I mean, just how lazy do you want to be? :lol:


Hm, what if you do not know it ? It would be logical to have cd <TAB> to show list of subdirectories in the current directory
Back to top
View user's profile Send private message
mv
Advocate
Advocate


Joined: 20 Apr 2005
Posts: 4009

PostPosted: Tue Jul 30, 2013 9:14 am    Post subject: Reply with quote

First of all: Switch to zsh. Its completion system (once properly setup and activated) is way better than what bash ever will perform.

That being said, IIRC the bash-completion script had some support for cd, pushd etc, but I remember that I had written my own function for that since the bash-completion script did more than I wanted. (Of course, I did this before I learnt to know zsh.)

Thus, I conjecture that your problem is actually related with the recent change of the ebuild in the bash-completion package which now has to be activated differently and which was apparently not documented sufficiently: Look for other threads (or in the gentoo-user mailing list) and the bugs mentioned in the ChangeLog how to do it now. (Since I am not using bash ineractively anymore, I did not remember the details.)
Back to top
View user's profile Send private message
defer-
Tux's lil' helper
Tux's lil' helper


Joined: 11 Jun 2007
Posts: 130
Location: Finland

PostPosted: Tue Jul 30, 2013 10:42 am    Post subject: Reply with quote

mv wrote:
First of all: Switch to zsh. Its completion system (once properly setup and activated) is way better than what bash ever will perform.


Is it hard to setup and get used to zsh? Is there really much difference? Does my .bashrc aliases/PS1, bash scripts and stuff like that work easily?
_________________
https://github.com/defer-
Back to top
View user's profile Send private message
truc
Advocate
Advocate


Joined: 25 Jul 2005
Posts: 3199

PostPosted: Tue Jul 30, 2013 12:58 pm    Post subject: Reply with quote

hehe,

<off>forget zsh, you want to use bash because it's almost as complete as zsh (oh well, almost almost...) and especially because it uses readline that you, poweruser, already know how to use extensively! </off>

To enable directory completion for cd, I have this:
Code:
complete -d cd

_________________
The End of the Internet!
Back to top
View user's profile Send private message
mv
Advocate
Advocate


Joined: 20 Apr 2005
Posts: 4009

PostPosted: Wed Jul 31, 2013 9:01 am    Post subject: OT: zsh Reply with quote

defer- wrote:
Is it hard to setup and get used to zsh? Is there really much difference?

In the default, zsh is almost as poor as bash, but setting up more features will show you more and more (useful) differences, especially for interactive usage.
For a quick start, you might want to install zshrc-mv from the mv overlay which sets up many things (I suggest to install also the other packages which the ebuild recommends). Try to see if it works by pressing
Code:
ls [Tab][Tab]

(or cd instead of ls) which acts similarly as in bash - just that the shown completions are colored according to your /etc/DIR_COLORS. You see the first magic if you press [Tab] a third time and use your cursor keys. Or if you press
Code:
ls -[Tab][Tab]

If you work longer with zsh you will learn useful features like empty commands
Code:
<textfiles

inline aliases
Code:
emerge -pve LESS

(The alias LESS from zshrc-mv contains redirection from stderr and stdin), extended globbing
Code:
ls *(/)

shortcuts for loops
Code:
for i in *; echo $i

etc. pp.
Quote:
Does my .bashrc aliases/PS1, bash scripts and stuff like that work easily?

zsh has a bash emulation mode so that your .bashrc aliases and functions work probably out-of-the-box if you source it in that mode (for a starters, you can try to define interactive=~/.bashrc in the beginning of /etc/zsh/zshrc). Practically the only thing which is not properly emulated is
Code:
[[ $variable ]]
which must be written in the more compatible way
Code:
[[ -n $variable ]]

The PS1-escape sequences in zsh are much more powerful than in bash but not compatible, so the same PS1-value as in bash will probably not look like you want. (However, e.g. set_prompt from the mv overlay can produce reasonable prompts for bash and zsh and is automatically used if you use zshrc-mv.)
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum