autocompletion

hi, i’m having some troubles enabling autocomplition for bash

the problem i’m having is when using sudo or zypper

any help is appreciated! (:

ps: is there any irc for opensuse community?

Remember you have to be in the root dir of the file name, if that’s what you were wanting to auto complete

oh, i see. but, say chmod for example

i can see i can autocomplete by going *sudo /bin/chmod *

but sudo chmod works, and when I write sudo ch it dosn’t get autocompleted, could it be possible?

sudo ch
chacl                            check-binary-files               chktrust
chage                            checkbrack                       chmod
chainsaw                         checkmedia                       chmorph
change_permissions_for_cdrtools  checkproc                        chooser
chat                             checkXML                         chown
chattr                           chessx                           chpasswd
chcon                            chfn                             chroot
chdist                           chgrp                            chrp-addnote
cheatmake                        chkconfig                        chrt
checkagents                      chkstat                          chsh
checkbashisms                    chkstat-polkit                   chvt

Obviously, yes.

bcurcio wrote:
> ps: is there any irc for opensuse community?

yep…we got most everything: IRC, mail list, web forum, nntp forum
and more…

get there from here: http://en.opensuse.org/Communicate


palladium

The shell tries autocompletion for the first word in a command line supposing it is a the name of an executable that can be found with your PATH environment variable.

The shell tries autocompletion for all the other fields in the command line with the filenames found in eithter the working directory, or when allready directories are given in a filename found in that path. This was designed because most often the other fields (and specialy when a user wants to use autocompletion) is much more likely to b a file then a command.

The shell does not know that in the case of the sudo executable one of the fields following it can be an executable itself. Thus it tries to autocomplete, but with the names of the files in your working directory.

In other words, when you try to autocomplete

sud

it seraches for executabls inside the directories mentioned in your PATH.
When

sudo /bin/chm

it searched for a file (not an executabl!) insid /bin
When

sudo chm

it searches for a file inside the current working directory (where you most probably do not have a file with the name chmod I suppose, but do a cd /bin first and it will find chmod).

@Akoellh
can not reproduce that here.

You did press TAB twice, did you?

Even thrice and more. It works with* sud , but not with sud ch *.

Well, I think I might know the reason why.

But have a look at this …

zypper in
info                    install                 installed               install-new-recommends

and I am sure this will work on your system, too but maybe this will not work

 rpm -q bas
bash             bash-completion  bash-doc  

(And the last command is a very big hint :-))

Exactly as you thought:

The first autocompleted, the second did not and indeed* bash-completion *is not installed.

What is in* bash-completetion*? More knowledge about the fields of several much used commands? When yes, would it help the OP to install this?

About zypper, what i was asking is if there’s such thing as an autocomplete for packages.
As in *zypper install ba *

And thanks about the bash-completion, for some reason I couldn’t find it in yast, but zypper install bash-completion worked fine! :wink:

Very good bcurcio. After a bad experience elsewhere it is a relief to see somebody who needs only half a sentence :slight_smile:

And I learned about bash-completion, but I do not think I am going to install/use it. In any case I am more fond of ksh.

I was wondering this as well.

On 05/04/2013 07:56 PM, chickenfeet wrote:
>
> bcurcio;2144260 Wrote:
>> About zypper, what i was asking is if there’s such thing as an
>> autocomplete for packages.
>> As in -zypper install ba -
> I was wondering this as well.

no need to wonder, it is ok to experiment . . .


dd

I’m going to try Zsh because I enjoyed it with the new Arch and its derivatives. It has more completions and auto-suggestions even.