zsh-users
 help / color / mirror / code / Atom feed
* sudo autocompletion
@ 2020-02-09 16:52 Andrey Butirsky
  2020-02-09 17:03 ` Roman Perepelitsa
  0 siblings, 1 reply; 5+ messages in thread
From: Andrey Butirsky @ 2020-02-09 16:52 UTC (permalink / raw)
  To: Zsh Users

Hi,

what is the most "canonical" way to get sudo <command> autocompleted for 
casual user?
In bash, it works out of the box. Shouldn't we provide the same?

I found many hacks about it and maybe since I'm new user they all looks 
pretty ugly.
So I decided to ask here than trying to reinvent the wheel..

Thanks.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: sudo autocompletion
  2020-02-09 16:52 sudo autocompletion Andrey Butirsky
@ 2020-02-09 17:03 ` Roman Perepelitsa
  2020-02-09 17:14   ` Andrey Butirsky
  0 siblings, 1 reply; 5+ messages in thread
From: Roman Perepelitsa @ 2020-02-09 17:03 UTC (permalink / raw)
  To: Andrey Butirsky; +Cc: Zsh Users

On Sun, Feb 9, 2020 at 5:53 PM Andrey Butirsky <butirsky@gmail.com> wrote:
>
> Hi,
>
> what is the most "canonical" way to get sudo <command> autocompleted for
> casual user?

It just works for me after calling compinit without having to set any
options or styles.

  sudo -u ro<TAB>  => romka (my username)
  sudo -u romka fgr<TAB> => fgrep
  sudo -u romka fgrep --a => --after-context

What doesn't work for you out of the box?

Roman.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: sudo autocompletion
  2020-02-09 17:03 ` Roman Perepelitsa
@ 2020-02-09 17:14   ` Andrey Butirsky
  2020-02-10  3:02     ` Daniel Shahaf
  0 siblings, 1 reply; 5+ messages in thread
From: Andrey Butirsky @ 2020-02-09 17:14 UTC (permalink / raw)
  To: Roman Perepelitsa; +Cc: Zsh Users

On 09.02.2020 20:03, Roman Perepelitsa wrote:
> What doesn't work for you out of the box?

What doesn't work is completion for 'privileged' commands, those in 
/usr/sbin/ etc.

I know I haven't PATH set for those, but in bash all of these just work.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: sudo autocompletion
  2020-02-09 17:14   ` Andrey Butirsky
@ 2020-02-10  3:02     ` Daniel Shahaf
  2020-02-10  7:52       ` Andrey
  0 siblings, 1 reply; 5+ messages in thread
From: Daniel Shahaf @ 2020-02-10  3:02 UTC (permalink / raw)
  To: Andrey Butirsky; +Cc: Roman Perepelitsa, Zsh Users

Andrey Butirsky wrote on Sun, 09 Feb 2020 20:14 +0300:
> On 09.02.2020 20:03, Roman Perepelitsa wrote:
> > What doesn't work for you out of the box?  
> 
> What doesn't work is completion for 'privileged' commands, those in 
> /usr/sbin/ etc.
> 
> I know I haven't PATH set for those, but in bash all of these just work.
> 

Something like this:

zstyle ':completion:*:*:sudo:*' command-path $path ${path//bin/sbin}

Adjust the stuff after «command-path» as needed.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: sudo autocompletion
  2020-02-10  3:02     ` Daniel Shahaf
@ 2020-02-10  7:52       ` Andrey
  0 siblings, 0 replies; 5+ messages in thread
From: Andrey @ 2020-02-10  7:52 UTC (permalink / raw)
  To: Daniel Shahaf; +Cc: Zsh Users

Thanks, will try it. How about to include it in distribution by default?

On February 10, 2020 6:02:19 AM GMT+03:00, Daniel Shahaf <d.s@daniel.shahaf.name> wrote:
>Something like this:
>
>zstyle ':completion:*:*:sudo:*' command-path $path ${path//bin/sbin}
>
>Adjust the stuff after «command-path» as needed.

-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-02-10  7:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-09 16:52 sudo autocompletion Andrey Butirsky
2020-02-09 17:03 ` Roman Perepelitsa
2020-02-09 17:14   ` Andrey Butirsky
2020-02-10  3:02     ` Daniel Shahaf
2020-02-10  7:52       ` Andrey

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).