Talk:TIP TAB-completion

From Gentoo Linux Wiki

Jump to: navigation, search

Contents

[edit] New bashrc location

I went ahead and changed the references to /root/.bashrc to /etc/bash/bashrc since it's the first location the shell scripts look to source the files. If you put it in .bashrc, the completion doesn't automatically take effect on login because .bashrc is never sourced. --Hechacker1 04:16, 14 May 2007 (UTC)

.profile is loaded on normal terminal and .bashrc on gnome-terminal ln -s .bashrc .profile

[edit] root user

How do I get this to work for my root user? Or better yet, how to make it global for all users? I tried putting it into /etc/profile but that didn't work.

--> root user: basically you have to make sure that when you open a shell or login, /etc/profile.d/bash-completion gets sourced. But you can also use bash-completion-config (I just added it to the article). tuxlover

[edit] ZSH

As far as I know for zsh-completion you also need to add this to your .zshrc to make it work:

autoload -Uz compinit
compinit


And in case you use your home-folder for multiple machines you can use this:

autoload -Uz compinit
compinit -d $(print -P "${ZDOTDIR:-$HOME}/.zcompdump_%m")

so you get your .zscompdump in this format: .zcompdump_${machinename}

[edit] Config

I dont have a /etc/.bashrc as mentioned. Has it changed to /etc/bash/bashrc ?

  • if there is none, just create one! -twix

[edit] Wont work...

Call me stupid but that all doesnt work for my freshly new gentoo. If i source /etc/profile.d/bash-completion and i try to use tab completion it doesnt work. On my previous gentoo that worked fine...

Yes bash-completion is in USE. And bash-completion-config -l tells me that modules like genlop or gentoo are installed... Anybody can help?

/etc/profile trying to load files in profile.d with this code:

for sh in /etc/profile.d/*.sh ; do
        if [ -r "$sh" ] ; then
                . "$sh"
        fi
done

But file /etc/profile.d/bash-completion can't be found with mask '*.sh'. You should rename bash-completion to bash-completion.sh or fix /etc/profile. Or just add . /etc/profile.d/bash-completion to your .bashrc. -- added by Jay 23.11.2007

[edit] /etc/env.d

how about using that instead of altering /etc/bash/bashrc? Don't know exactly how and when these scripts get sourced... Cinquero

[edit] eix?

"eselect bashcomp list" doesnt list eix, yet the article shows it as example, bug?

[edit] non-login shells

It is imho better to put the

[[ -f /etc/profile.d/bash-completion ]] && source /etc/profile.d/bash-completion

in /etc/bash/bashrc since it is sourced by both login and non-login shells.

[edit] ls --color=never

The command from "enabling all tab completion" failed on my terminal because of color output of ls:

for i in `ls /usr/share/bash-completion/`; do ln -s /usr/share/bash-completion/$i ~/.bash_completion.d/$i; done

So I suggest

for i in `ls --color=never /usr/share/bash-completion/`; do ln -s /usr/share/bash-completion/$i ~/.bash_completion.d/$i; done
.