complete choices for a2enmod / a2dismod etc. #2141

Closed
n3o77 opened this Issue Jun 20, 2015 · 13 comments

Comments

Projects
None yet
3 participants
@n3o77

n3o77 commented Jun 20, 2015

i'm having trouble to get auto completion running for a2enmod, a2dismod, a2ensite and so on. with bash i can just type "a2enmod " and get a list of all available mods. is there a way to do this with fish as well? another problem i'm having is that i don't get proper suggestions for sudo. when i'm typing as my user "sudo a2e" I don't get any suggestions, but executing "sudo a2enmod" works just fine.

thank you very much in advance!

@zanchey

This comment has been minimized.

Show comment
Hide comment
@zanchey

zanchey Jun 26, 2015

Member

The first problem is easy enough to fix - completions for a2{en,dis}{mod,site} are pretty easy to write.

The second example works fine for me on 2.1.1 and 2.2b1 - what version are you running?

Member

zanchey commented Jun 26, 2015

The first problem is easy enough to fix - completions for a2{en,dis}{mod,site} are pretty easy to write.

The second example works fine for me on 2.1.1 and 2.2b1 - what version are you running?

@zanchey zanchey added this to the next-2.x milestone Jun 26, 2015

@n3o77

This comment has been minimized.

Show comment
Hide comment
@n3o77

n3o77 Jun 26, 2015

Thank you very much!
I'm running version 2.1.1 on debian wheezy.

n3o77 commented Jun 26, 2015

Thank you very much!
I'm running version 2.1.1 on debian wheezy.

@faho

This comment has been minimized.

Show comment
Hide comment
@faho

faho Jul 16, 2015

Member

The completions are now written, so the question remains:

Is the sudo thing still occuring? Does it also happen with fish 2.2.0?

Member

faho commented Jul 16, 2015

The completions are now written, so the question remains:

Is the sudo thing still occuring? Does it also happen with fish 2.2.0?

@n3o77

This comment has been minimized.

Show comment
Hide comment
@n3o77

n3o77 Jul 16, 2015

Yes, I'm still having the problem with sudo in 2.2.0. Completions aren't in 2.2.0, right?

n3o77 commented Jul 16, 2015

Yes, I'm still having the problem with sudo in 2.2.0. Completions aren't in 2.2.0, right?

@faho

This comment has been minimized.

Show comment
Hide comment
@faho

faho Jul 16, 2015

Member

No, they aren't - though you can download them manually and add them to ~/.config/fish/completions/.

Do you have any sudo function/alias (type sudo)? Otherwise __fish_complete_subcommand_root is not working as it should.

Member

faho commented Jul 16, 2015

No, they aren't - though you can download them manually and add them to ~/.config/fish/completions/.

Do you have any sudo function/alias (type sudo)? Otherwise __fish_complete_subcommand_root is not working as it should.

@n3o77

This comment has been minimized.

Show comment
Hide comment
@n3o77

n3o77 Jul 16, 2015

OK i just took another look and it seems that it's partially Working. See screenshots.

/v/www  type sudo
sudo is /usr/bin/sudo

As user:
screen shot 2015-07-16 at 20 20 19

As root:
screen shot 2015-07-16 at 20 24 52

n3o77 commented Jul 16, 2015

OK i just took another look and it seems that it's partially Working. See screenshots.

/v/www  type sudo
sudo is /usr/bin/sudo

As user:
screen shot 2015-07-16 at 20 20 19

As root:
screen shot 2015-07-16 at 20 24 52

@faho

This comment has been minimized.

Show comment
Hide comment
@faho

faho Jul 16, 2015

Member

I have an idea:

 getfacl (which a2enmod)

It appears that fish will not complete commands you can't execute (though I'll be damned if I find where that's defined).

Member

faho commented Jul 16, 2015

I have an idea:

 getfacl (which a2enmod)

It appears that fish will not complete commands you can't execute (though I'll be damned if I find where that's defined).

@n3o77

This comment has been minimized.

Show comment
Hide comment
@n3o77

n3o77 Jul 16, 2015

root@my ~# getfacl (which a2enmod)
getfacl: Removing leading '/' from absolute path names
# file: usr/sbin/a2enmod
# owner: root
# group: root
user::rwx
group::r-x
other::r-x

n3o77 commented Jul 16, 2015

root@my ~# getfacl (which a2enmod)
getfacl: Removing leading '/' from absolute path names
# file: usr/sbin/a2enmod
# owner: root
# group: root
user::rwx
group::r-x
other::r-x
@zanchey

This comment has been minimized.

Show comment
Hide comment
@zanchey

zanchey Jul 17, 2015

Member

I think the problem here is that because PATH is set as a local variable in the __fish_complete_subcommand_root scope, it is not reflected in the __fish_complete_subcommand scope.

Certainly adding --no-scope-shadowing to the definition of __fish_complete_subcommand seems to fix things.

I'm wondering if this got broken by the change to top-level scoping or something, although I doubt it.

Member

zanchey commented Jul 17, 2015

I think the problem here is that because PATH is set as a local variable in the __fish_complete_subcommand_root scope, it is not reflected in the __fish_complete_subcommand scope.

Certainly adding --no-scope-shadowing to the definition of __fish_complete_subcommand seems to fix things.

I'm wondering if this got broken by the change to top-level scoping or something, although I doubt it.

@zanchey

This comment has been minimized.

Show comment
Hide comment
@zanchey

zanchey Jul 17, 2015

Member

This worked in 1.23.1 (!) but I think b0c6d89 broke it well before 2.0.0. I don't think the change is wrong; certainly it doesn't seem wise to alter the global PATH, but I'm not 100% sure that --no-scope-shadowing is sensible in __fish_complete_subcommand; thoughts welcome!

Member

zanchey commented Jul 17, 2015

This worked in 1.23.1 (!) but I think b0c6d89 broke it well before 2.0.0. I don't think the change is wrong; certainly it doesn't seem wise to alter the global PATH, but I'm not 100% sure that --no-scope-shadowing is sensible in __fish_complete_subcommand; thoughts welcome!

@faho

This comment has been minimized.

Show comment
Hide comment
@faho

faho Aug 5, 2015

Member

Either adding an option to __fish_complete_subcommand or duplicating it in __fish_complete_subcommand_root should work.

Member

faho commented Aug 5, 2015

Either adding an option to __fish_complete_subcommand or duplicating it in __fish_complete_subcommand_root should work.

@faho

This comment has been minimized.

Show comment
Hide comment
@faho

faho Sep 28, 2015

Member

I'm not 100% sure that --no-scope-shadowing is sensible in __fish_complete_subcommand; thoughts welcome!

@zanchey: As far as I understand, "--no-scope-shadowing" means that the calling "local" scope is inherited, right? __fish_complete_subcommand defines all variables it uses as local and __fish_complete_subcommand_root doesn't use any variables of the same name after the call (in fact it does nothing).

So I don't see any bugs popping up because of that change - though it'd mean we'd have to be careful. But given that the last change to __fish_complete_subcommand was in 2012, I think it's rather stable.

The other options I see are:

  • Duplicate __fish_complete_subcommand's logic in __f_c_s_r (as in "literally copy all the code in")
  • Add an option to __f_c_s to take a path
Member

faho commented Sep 28, 2015

I'm not 100% sure that --no-scope-shadowing is sensible in __fish_complete_subcommand; thoughts welcome!

@zanchey: As far as I understand, "--no-scope-shadowing" means that the calling "local" scope is inherited, right? __fish_complete_subcommand defines all variables it uses as local and __fish_complete_subcommand_root doesn't use any variables of the same name after the call (in fact it does nothing).

So I don't see any bugs popping up because of that change - though it'd mean we'd have to be careful. But given that the last change to __fish_complete_subcommand was in 2012, I think it's rather stable.

The other options I see are:

  • Duplicate __fish_complete_subcommand's logic in __f_c_s_r (as in "literally copy all the code in")
  • Add an option to __f_c_s to take a path

@zanchey zanchey self-assigned this Oct 21, 2015

@zanchey

This comment has been minimized.

Show comment
Hide comment
@zanchey

zanchey Oct 21, 2015

Member

I went with the easy option in f68b339 - this should work now.

Member

zanchey commented Oct 21, 2015

I went with the easy option in f68b339 - this should work now.

@zanchey zanchey closed this in f21d826 Oct 21, 2015

@faho faho added the release notes label Oct 26, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment