[-- Attachment #1: Type: text/plain, Size: 858 bytes --] Hello, there are some completion functions that aren't loaded, it appears. > functions _systemctl _systemctl () { # undefined builtin autoload -XUz } systemctl<tab> the output is from _files systemctl<ctrl-h> tags in context :completion::complete:SYSTEMD_PAGER=:: argument-rest (_arguments _gnu_generic) tags in context :completion::complete:SYSTEMD_PAGER=:argument-rest: use-compctl (_default _arguments _gnu_generic) globbed-files (_files _default _arguments _gnu_generic) tags in context :completion::complete:sudo:: argument-rest (_arguments _sudo) it's not even listed. The completion function is defined in /usr/share/zsh/vendor-completions the dir is present in $fpath and other completion function from the same directory are working correctly. What can I do to debug the issue? thanks Pier Paolo Grassi [-- Attachment #2: Type: text/html, Size: 1378 bytes --]
On Sat, Feb 11, 2023 at 1:19 PM Pier Paolo Grassi <pierpaolog@gmail.com> wrote: > > Hello, there are some completion functions that aren't loaded, it appears. > > it's not even listed. The completion function is defined in > /usr/share/zsh/vendor-completions That means it's provided by the OS zsh package, it's not present in the zsh source tree. > What can I do to debug the issue? Check that the file starts with either #compdef ... or #autoload
[-- Attachment #1: Type: text/plain, Size: 931 bytes --] : head /usr/share/zsh/vendor-completions/_systemctl #compdef systemctl (( $+functions[_systemctl_command] )) || _systemctl_command() { local -a _systemctl_cmds _systemctl_cmds=( "list-sockets:List sockets" "list-timers:List timers" "list-units:List units" "start:Start (activate) one or more units" Pier Paolo Grassi Il giorno sab 11 feb 2023 alle ore 22:27 Bart Schaefer < schaefer@brasslantern.com> ha scritto: > On Sat, Feb 11, 2023 at 1:19 PM Pier Paolo Grassi <pierpaolog@gmail.com> > wrote: > > > > Hello, there are some completion functions that aren't loaded, it > appears. > > > > it's not even listed. The completion function is defined in > > /usr/share/zsh/vendor-completions > > That means it's provided by the OS zsh package, it's not present in > the zsh source tree. > > > What can I do to debug the issue? > > Check that the file starts with either > > #compdef ... > > or > > #autoload > [-- Attachment #2: Type: text/html, Size: 1657 bytes --]
On Sat, Feb 11, 2023 at 1:27 PM Bart Schaefer <schaefer@brasslantern.com> wrote:
>
> > What can I do to debug the issue?
>
> Check that the file starts with either
>
> #compdef ...
>
> or
>
> #autoload
Sorry, accidentally sent too soon.
And that the #compdef line mentions the "systemctl" command. You can
also check $_comps[systemctl], it's possible that something else
loaded later is replacing it.
[-- Attachment #1: Type: text/plain, Size: 818 bytes --] echo $_comps[systemctl] _systemctl I think that is the only definition of this function that I have the strange thing is that it's not autoloaded even if it is scheduled to do so is it possibile that some error prevents it from loading? Pier Paolo Grassi Il giorno sab 11 feb 2023 alle ore 22:31 Bart Schaefer < schaefer@brasslantern.com> ha scritto: > On Sat, Feb 11, 2023 at 1:27 PM Bart Schaefer <schaefer@brasslantern.com> > wrote: > > > > > What can I do to debug the issue? > > > > Check that the file starts with either > > > > #compdef ... > > > > or > > > > #autoload > > Sorry, accidentally sent too soon. > > And that the #compdef line mentions the "systemctl" command. You can > also check $_comps[systemctl], it's possible that something else > loaded later is replacing it. > -- Pier Paolo Grassi [-- Attachment #2: Type: text/html, Size: 1696 bytes --]
On Sun, Feb 12, 2023 at 9:23 AM Pier Paolo Grassi <pierpaolog@gmail.com> wrote:
>
> the strange thing is that it's not autoloaded even if it is scheduled to do so
> is it possibile that some error prevents it from loading?
Yes; try
autoload +X _systemctl
[-- Attachment #1: Type: text/plain, Size: 635 bytes --] It doesn't seem to do anything. Even inserting setopt xtrace just after #compdef systemctl in /usr/share/zsh/vendor-completions/_systemctl does not produce any output when trying to complete the systemctl command after opening a new shell Pier Paolo Grassi Il giorno dom 12 feb 2023 alle ore 18:41 Bart Schaefer < schaefer@brasslantern.com> ha scritto: > On Sun, Feb 12, 2023 at 9:23 AM Pier Paolo Grassi <pierpaolog@gmail.com> > wrote: > > > > the strange thing is that it's not autoloaded even if it is scheduled to > do so > > is it possibile that some error prevents it from loading? > > Yes; try > autoload +X _systemctl > [-- Attachment #2: Type: text/html, Size: 1258 bytes --]
[-- Attachment #1: Type: text/plain, Size: 960 bytes --] autoload +X _systemctl does not produce any output, but it does not gives an error though but the completion context for systemctl does not change, _systemctl is not present Pier Paolo Grassi Il giorno dom 12 feb 2023 alle ore 18:52 Pier Paolo Grassi < pierpaolog@gmail.com> ha scritto: > It doesn't seem to do anything. Even inserting > setopt xtrace > > just after #compdef systemctl > in /usr/share/zsh/vendor-completions/_systemctl does not produce any output > when trying to complete the systemctl command after opening a new shell > > Pier Paolo Grassi > > > Il giorno dom 12 feb 2023 alle ore 18:41 Bart Schaefer < > schaefer@brasslantern.com> ha scritto: > >> On Sun, Feb 12, 2023 at 9:23 AM Pier Paolo Grassi <pierpaolog@gmail.com> >> wrote: >> > >> > the strange thing is that it's not autoloaded even if it is scheduled >> to do so >> > is it possibile that some error prevents it from loading? >> >> Yes; try >> autoload +X _systemctl >> > [-- Attachment #2: Type: text/html, Size: 2027 bytes --]
[-- Attachment #1: Type: text/plain, Size: 1431 bytes --] sorry, too soon... autoload +X _systemctl does not produce any output, but it does not gives an error though but the completion context for systemctl does not change, _systemctl is not present, even after a compdef _systemctl systemctl but functions _systemctl now returns the correctly loaded function body Pier Paolo Grassi Il giorno dom 12 feb 2023 alle ore 19:13 Pier Paolo Grassi < pierpaolog@gmail.com> ha scritto: > autoload +X _systemctl > > does not produce any output, but it does not gives an error though > but the completion context for systemctl does not change, _systemctl is > not present > > Pier Paolo Grassi > > > Il giorno dom 12 feb 2023 alle ore 18:52 Pier Paolo Grassi < > pierpaolog@gmail.com> ha scritto: > >> It doesn't seem to do anything. Even inserting >> setopt xtrace >> >> just after #compdef systemctl >> in /usr/share/zsh/vendor-completions/_systemctl does not produce any output >> when trying to complete the systemctl command after opening a new shell >> >> Pier Paolo Grassi >> >> >> Il giorno dom 12 feb 2023 alle ore 18:41 Bart Schaefer < >> schaefer@brasslantern.com> ha scritto: >> >>> On Sun, Feb 12, 2023 at 9:23 AM Pier Paolo Grassi <pierpaolog@gmail.com> >>> wrote: >>> > >>> > the strange thing is that it's not autoloaded even if it is scheduled >>> to do so >>> > is it possibile that some error prevents it from loading? >>> >>> Yes; try >>> autoload +X _systemctl >>> >> [-- Attachment #2: Type: text/html, Size: 2995 bytes --]
On Sun, Feb 12, 2023 at 7:28 PM Pier Paolo Grassi <pierpaolog@gmail.com> wrote:
>
> sorry, too soon...
>
> autoload +X _systemctl
>
> does not produce any output, but it does not gives an error though
> but the completion context for systemctl does not change, _systemctl is not present,
> even after a
> compdef _systemctl systemctl
This works though, right?
\systemctl <TAB>
(Note the backslash).
If the answer is yes (I assume it is), what's the output of `alias systemctl`?
Roman.
[-- Attachment #1: Type: text/plain, Size: 758 bytes --] oh, yikes... alias systemctl='sudo SYSTEMD_PAGER= systemctl' sorry, totally forgotten about that Pier Paolo Grassi Il giorno dom 12 feb 2023 alle ore 19:36 Roman Perepelitsa < roman.perepelitsa@gmail.com> ha scritto: > On Sun, Feb 12, 2023 at 7:28 PM Pier Paolo Grassi <pierpaolog@gmail.com> > wrote: > > > > sorry, too soon... > > > > autoload +X _systemctl > > > > does not produce any output, but it does not gives an error though > > but the completion context for systemctl does not change, _systemctl is > not present, > > even after a > > compdef _systemctl systemctl > > This works though, right? > > \systemctl <TAB> > > (Note the backslash). > > If the answer is yes (I assume it is), what's the output of `alias > systemctl`? > > Roman. > [-- Attachment #2: Type: text/html, Size: 1440 bytes --]
On Sun, Feb 12, 2023 at 9:58 PM Pier Paolo Grassi <pierpaolog@gmail.com> wrote:
>
> alias systemctl='sudo SYSTEMD_PAGER= systemctl'
If you replace the alias with a function, it'll complete nicely.
systemctl() sudo SYSTEMD_PAGER= systemctl "$@"
Alternatively, you can `setopt complete_aliases` and then manually
`compdef` every alias. I'm not a fan of this approach but it's an
option.
Roman.
[-- Attachment #1: Type: text/plain, Size: 605 bytes --] yes i am now adapting these aliases to functions, thanks Il giorno dom 12 feb 2023 alle 22:08 Roman Perepelitsa < roman.perepelitsa@gmail.com> ha scritto: > On Sun, Feb 12, 2023 at 9:58 PM Pier Paolo Grassi <pierpaolog@gmail.com> > wrote: > > > > alias systemctl='sudo SYSTEMD_PAGER= systemctl' > > If you replace the alias with a function, it'll complete nicely. > > systemctl() sudo SYSTEMD_PAGER= systemctl "$@" > > Alternatively, you can `setopt complete_aliases` and then manually > `compdef` every alias. I'm not a fan of this approach but it's an > option. > > Roman. > -- Pier Paolo Grassi [-- Attachment #2: Type: text/html, Size: 1166 bytes --]
On Sun, Feb 12, 2023 at 1:08 PM Roman Perepelitsa
<roman.perepelitsa@gmail.com> wrote:
>
> On Sun, Feb 12, 2023 at 9:58 PM Pier Paolo Grassi <pierpaolog@gmail.com> wrote:
> >
> > alias systemctl='sudo SYSTEMD_PAGER= systemctl'
>
> If you replace the alias with a function, it'll complete nicely.
sudo completion is supposed to know how to look ahead. As written
above, the completion context is
tags in context :completion::complete:SYSTEMD_PAGER=::
use-compctl (_default)
globbed-files (_files _default)
tags in context :completion::complete:sudo::
argument-rest (_arguments _sudo)
The alias would work if it were instead
alias systemctl='SYSTEMD_PAGER= sudo systemctl'
Maybe this indicates need for a fix to _sudo
On Sun, Feb 12, 2023 at 10:53 PM Bart Schaefer <schaefer@brasslantern.com> wrote: > > The alias would work if it were instead > > alias systemctl='SYSTEMD_PAGER= sudo systemctl' Keep in mind that on most systems with the default settings SYSTEMD_PAGER won't be propagated through sudo. > Maybe this indicates need for a fix to _sudo Nod. Roman.
[-- Attachment #1: Type: text/plain, Size: 593 bytes --] in my ubuntu the env var is not propagated if moved before sudo, the function works correctly Il giorno lun 13 feb 2023 alle 09:23 Roman Perepelitsa < roman.perepelitsa@gmail.com> ha scritto: > On Sun, Feb 12, 2023 at 10:53 PM Bart Schaefer > <schaefer@brasslantern.com> wrote: > > > > The alias would work if it were instead > > > > alias systemctl='SYSTEMD_PAGER= sudo systemctl' > > Keep in mind that on most systems with the default settings > SYSTEMD_PAGER won't be propagated through sudo. > > > Maybe this indicates need for a fix to _sudo > > Nod. > > Roman. > -- Pier Paolo Grassi [-- Attachment #2: Type: text/html, Size: 1095 bytes --]