ksh complete_command for commands with "-" in name

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

ksh complete_command for commands with "-" in name

Uwe Werler
Hi misc,

I use heavily the feature to set command completion in ksh. Unfortunately this doesn't work for commands with "-" (like ssh-add, salt-call etc.) in command name because the parameter name for the array is invalid. Any idea to work around that or plans to allow at least "-" when parameter name starts with "complete_"? I'm not a developer and don't really understand the code for ksh :/

Thanks in advance.

Uwe

Reply | Threaded
Open this post in threaded view
|

Re: ksh complete_command for commands with "-" in name

Ottavio Caruso
On Fri, 17 Jan 2020 at 22:03, Uwe Werler <[hidden email]> wrote:
>
> Hi misc,
>
> I use heavily the feature to set command completion in ksh. Unfortunately this doesn't work for commands with "-" (like ssh-add, salt-call etc.) in command name because the parameter name for the array is invalid.

I'm not sure if I'm getting what you're saying. I have a barebone
plain-vanilla OpenBSD 6.6 installation and I have ksh as my login
shell. I can do command and file completion with [TAB] on any commands
with a hyphen (pkg-config, ssh-add, ssh-agent, ssh-keygen, ssh-keyscan
and so on).

--
Ottavio Caruso

Reply | Threaded
Open this post in threaded view
|

Re: ksh complete_command for commands with "-" in name

Uwe Werler
On 17 Jan 22:32, Ottavio Caruso wrote:

> On Fri, 17 Jan 2020 at 22:03, Uwe Werler <[hidden email]> wrote:
> >
> > Hi misc,
> >
> > I use heavily the feature to set command completion in ksh. Unfortunately
> > this doesn't work for commands with "-" (like ssh-add, salt-call etc.) in
> > command name because the parameter name for the array is invalid.
>
> I'm not sure if I'm getting what you're saying. I have a barebone
> plain-vanilla OpenBSD 6.6 installation and I have ksh as my login
> shell. I can do command and file completion with [TAB] on any commands
> with a hyphen (pkg-config, ssh-add, ssh-agent, ssh-keygen, ssh-keyscan
> and so on).

From man 1 ksh:

             Custom completions may be configured by creating an array named
             ‘complete_command’, optionally suffixed with an argument number
             to complete only for a single argument.  So defining an array
             named ‘complete_kill’ provides possible completions for any
             argument to the kill(1) command, but ‘complete_kill_1’ only
             completes the first argument.  For example, the following command
             makes ksh offer a selection of signal names for the first
             argument to kill(1):

                   set -A complete_kill_1 -- -9 -HUP -INFO -KILL -TERM

This of course can't work for commands with a hyphen because the parameter name
of the array is then invalid.

Uwe

Reply | Threaded
Open this post in threaded view
|

Re: ksh complete_command for commands with "-" in name

Andreas Kusalananda Kähäri-4
On Fri, Jan 17, 2020 at 10:41:30PM +0000, Uwe Werler wrote:

> On 17 Jan 22:32, Ottavio Caruso wrote:
> > On Fri, 17 Jan 2020 at 22:03, Uwe Werler <[hidden email]> wrote:
> > >
> > > Hi misc,
> > >
> > > I use heavily the feature to set command completion in ksh. Unfortunately
> > > this doesn't work for commands with "-" (like ssh-add, salt-call etc.) in
> > > command name because the parameter name for the array is invalid.
> >
> > I'm not sure if I'm getting what you're saying. I have a barebone
> > plain-vanilla OpenBSD 6.6 installation and I have ksh as my login
> > shell. I can do command and file completion with [TAB] on any commands
> > with a hyphen (pkg-config, ssh-add, ssh-agent, ssh-keygen, ssh-keyscan
> > and so on).
>
> >From man 1 ksh:
>
>              Custom completions may be configured by creating an array named
>              ‘complete_command’, optionally suffixed with an argument number
>              to complete only for a single argument.  So defining an array
>              named ‘complete_kill’ provides possible completions for any
>              argument to the kill(1) command, but ‘complete_kill_1’ only
>              completes the first argument.  For example, the following command
>              makes ksh offer a selection of signal names for the first
>              argument to kill(1):
>
>                    set -A complete_kill_1 -- -9 -HUP -INFO -KILL -TERM
>
> This of course can't work for commands with a hyphen because the parameter name
> of the array is then invalid.
>
> Uwe

A somewhat ugly workaround would be to define aliases for the commands
that you want te install these completions for.  The aliases would have
no dashes in their names.

        alias ssh_add=ssh-add
        set -A complete_ssh_add_1 -- -D -l -L -v

--
Andreas (Kusalananda) Kähäri
SciLifeLab, NBIS, ICM
Uppsala University, Sweden

.

Reply | Threaded
Open this post in threaded view
|

Re: ksh complete_command for commands with "-" in name

Uwe Werler
On 18 Jan 00:27, Andreas Kusalananda Kähäri wrote:

> On Fri, Jan 17, 2020 at 10:41:30PM +0000, Uwe Werler wrote:
> > On 17 Jan 22:32, Ottavio Caruso wrote:
> > > On Fri, 17 Jan 2020 at 22:03, Uwe Werler <[hidden email]> wrote:
> > > >
> > > > Hi misc,
> > > >
> > > > I use heavily the feature to set command completion in ksh. Unfortunately
> > > > this doesn't work for commands with "-" (like ssh-add, salt-call etc.) in
> > > > command name because the parameter name for the array is invalid.
> > >
> > > I'm not sure if I'm getting what you're saying. I have a barebone
> > > plain-vanilla OpenBSD 6.6 installation and I have ksh as my login
> > > shell. I can do command and file completion with [TAB] on any commands
> > > with a hyphen (pkg-config, ssh-add, ssh-agent, ssh-keygen, ssh-keyscan
> > > and so on).
> >
> > >From man 1 ksh:
> >
> >              Custom completions may be configured by creating an array named
> >              ‘complete_command’, optionally suffixed with an argument number
> >              to complete only for a single argument.  So defining an array
> >              named ‘complete_kill’ provides possible completions for any
> >              argument to the kill(1) command, but ‘complete_kill_1’ only
> >              completes the first argument.  For example, the following command
> >              makes ksh offer a selection of signal names for the first
> >              argument to kill(1):
> >
> >                    set -A complete_kill_1 -- -9 -HUP -INFO -KILL -TERM
> >
> > This of course can't work for commands with a hyphen because the parameter name
> > of the array is then invalid.
> >
> > Uwe
>
> A somewhat ugly workaround would be to define aliases for the commands
> that you want te install these completions for.  The aliases would have
> no dashes in their names.
>
> alias ssh_add=ssh-add
> set -A complete_ssh_add_1 -- -D -l -L -v

Yeah, that's what I came up with too.