You are not logged in.
Pages: 1
Topic closed
I have trouble with bash completion and sudo. e.g. if I type "shut" and hit tab the "shutdown" get autocompleted. However, "sudo shut" <tab> does not work. Any ideas?
Last edited by Allan (2008-03-18 04:55:05)
Offline
add this to your .bashrc
complete -cf sudo
Offline
Thanks. that fixed it!
Offline
I just noticed that adding
complete -cf sudo
to ~/.bashrc breaks completion. As user
$ cd .i
.icons/ .inkscape/ .inputrc .inputrc~ .irssi/
Who wants to cd to a file? Files are not listed if you remove 'complete -cf sudo' line. Any other way to include the sudo to completion?
Offline
Edit: Don't you get that even without this line... I just tested both and it seems to happen.
Last edited by Allan (2008-05-27 12:13:13)
Offline
I thought bash completion was dumb, ie it had no concept of the arguments before in completing a filename. It would be neat if it did though!
Offline
hmm, it worked in ssh connection and now I tested it
$ ssh localhost
$ cd .i
.icons/ .inkscape/ .irssi/
So this is related to ssh then. But still weird and it is not affected by 'complete -cf sudo' line.
Last edited by Purch (2008-05-27 16:39:03)
Offline
zsh seems to have this clever auto-complete, it doesn't propose files to me on completing cd.
Offline
add this to your .bashrc
complete -cf sudo
Does anyone know the zsh equivalent for this?
ᶘ ᵒᴥᵒᶅ
Offline
For me, bash doesn't try to cd into files either with bash completion.
[git] | [AURpkgs] | [arch-games]
Offline
I thought bash completion was dumb, ie it had no concept of the arguments before in completing a filename. It would be neat if it did though!
Maybe you mean bash' tab completion.
- tab completion is the built-in tab completion in bash (and other shells)
- bash completion is an additional feature for bash (eg package bash-completion ). I'm not sure if it's installed by default
< Daenyth> and he works prolifically
4 8 15 16 23 42
Offline
What's strange for me is it previously worked in .bashrc. Then it just sort of stopped. Now I have it wrapped in .bashrc and it works:
if [ "$PS1" ]; then
complete -cf sudo
fi
Offline
hacosta wrote:add this to your .bashrc
complete -cf sudo
Does anyone know the zsh equivalent for this?
Actually, i meant sudo completion when going back in the zsh history, but now i'm getting more offtopic..
ᶘ ᵒᴥᵒᶅ
Offline
Is there a way to enable bash completion with aliases .
I use 'Q' as an alias for 'pacman -Q' .
In zsh :
$ Q lx (then tab)
$ Q lx
lxappearance lxlauncher lxrandr lxsplit lxterminal
lxde-common lxpanel lxsession-lite lxtask
'completion works '
In bash :
$ pacman -Q lx (then 2 tabs)
$ pacman -Q lx
lxappearance lxlauncher lxrandr lxsplit lxterminal
lxde-common lxpanel lxsession-lite lxtask
'completion works '
but with :
$ Q lx (then 2 tabs)
'It doesn't work'
English is not my native language .
Offline
add this to your .bashrc
complete -cf sudo
At the risk of necro-bumping, I want to add a comment that this is completely incorrect. This thread led me astray. The above command will prevent bash from using the correct completion for commands that follow sudo. It will instead try suggest files as the completion for any commands that follow sudo. See this stack overflow answer.
Offline
"the risk"? You've just made a new record by reviving a 12-year old thread.
Mods are just community members who have the occasionally necessary option to move threads around and edit posts. -- Trilby
Offline
Closing this old thread.
Offline
Pages: 1
Topic closed