My terminal autocompletion does not work properly when I use root.
source /etc/bash_completion
works if I invoke that manually.
I need to write above code in every new root terminal to be able to use autocompletion.
My terminal autocompletion does not work properly when I use root.
source /etc/bash_completion
works if I invoke that manually.
I need to write above code in every new root terminal to be able to use autocompletion.
You need to add it to ~/.bashrc
, not bash_profile, in this case... but you'll want to only apply it to interactive shells, to avoid taking time whenever you run a script:
case $- in
*i*) # interactive shell
source /etc/bash_completion;;
esac
You may need to add to /root/.bashrc
for it to work as root... but why are you running a shell as root instead of using sudo for individual commands?
Put this line to ~/.bash_profile
:
. /etc/bash_completion
PS1
has nothing to do with interactive shells, actually. Some distributions ship with files that use that, but it's wrong. Interactive shells havei
in their options in$-
(even if it wasn't passed explicitly on the command line). – Gilles 'SO- stop being evil' Sep 28 '12 at 22:56