zsh-users
 help / color / Atom feed
* completion is over thinking things.
@ 2019-09-28 17:05 Ray Andrews
  2019-09-28 17:13 ` Roman Perepelitsa
  2019-09-28 17:14 ` gmail
  0 siblings, 2 replies; 13+ messages in thread
From: Ray Andrews @ 2019-09-28 17:05 UTC (permalink / raw)
  To: Zsh Users

    $ ls inst.deb
    inst.deb

    $ apt-get install inst. [TAB]
    Completing package
    libapt-inst2.0
    libmono-system-configuration-install4.0-cil
    libmono-system-runtime-durableinstancing4.0-cil

How can I get completion to stop looking and finding files God knows 
where and just expand filenames in the current directory?




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

* Re: completion is over thinking things.
  2019-09-28 17:05 completion is over thinking things Ray Andrews
@ 2019-09-28 17:13 ` Roman Perepelitsa
  2019-09-28 17:36   ` Ray Andrews
  2019-09-28 17:14 ` gmail
  1 sibling, 1 reply; 13+ messages in thread
From: Roman Perepelitsa @ 2019-09-28 17:13 UTC (permalink / raw)
  To: Ray Andrews; +Cc: Zsh Users

On Sat, Sep 28, 2019 at 7:06 PM Ray Andrews <rayandrews@eastlink.ca> wrote:
>
>     $ ls inst.deb
>     inst.deb
>
>     $ apt-get install inst. [TAB]
>     Completing package
>     libapt-inst2.0
>     libmono-system-configuration-install4.0-cil
>     libmono-system-runtime-durableinstancing4.0-cil
>
> How can I get completion to stop looking and finding files God knows
> where and just expand filenames in the current directory?

This doesn't answer your question but `apt-get install inst.deb` won't
install ./inst.deb. Instead, it'll install all packages that partially
match regex `inst.deb`. You might be looking for `dpkg -i inst.deb`,
which conveniently also completes `inst.[TAB]` as you would expect.

Roman.

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

* Re: completion is over thinking things.
  2019-09-28 17:05 completion is over thinking things Ray Andrews
  2019-09-28 17:13 ` Roman Perepelitsa
@ 2019-09-28 17:14 ` gmail
  1 sibling, 0 replies; 13+ messages in thread
From: gmail @ 2019-09-28 17:14 UTC (permalink / raw)
  To: Ray Andrews, Zsh Users

Hello.

Installing packages from local .deb files is not the task for apt-get.
You should use `dpkg -i` instead.
Try this: https://superuser.com/questions/196864/how-to-install-local-deb-packages-with-apt-get#196867


28.09.2019, 20:06, "Ray Andrews" <rayandrews@eastlink.ca>:
>     $ ls inst.deb
>     inst.deb
>
>     $ apt-get install inst. [TAB]
>     Completing package
>     libapt-inst2.0
>     libmono-system-configuration-install4.0-cil
>     libmono-system-runtime-durableinstancing4.0-cil
>
> How can I get completion to stop looking and finding files God knows
> where and just expand filenames in the current directory?

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

* Re: completion is over thinking things.
  2019-09-28 17:13 ` Roman Perepelitsa
@ 2019-09-28 17:36   ` Ray Andrews
  2019-09-29  4:47     ` dana
  2019-09-29 13:09     ` Mikael Magnusson
  0 siblings, 2 replies; 13+ messages in thread
From: Ray Andrews @ 2019-09-28 17:36 UTC (permalink / raw)
  To: zsh-users

On 2019-09-28 10:13 a.m., Roman Perepelitsa wrote:
> On Sat, Sep 28, 2019 at 7:06 PM Ray Andrews <rayandrews@eastlink.ca> wrote:
>>      $ ls inst.deb
>>      inst.deb
>>
>>      $ apt-get install inst. [TAB]
>>      Completing package
>>      libapt-inst2.0
>>      libmono-system-configuration-install4.0-cil
>>      libmono-system-runtime-durableinstancing4.0-cil
>>
>> How can I get completion to stop looking and finding files God knows
>> where and just expand filenames in the current directory?
> This doesn't answer your question but `apt-get install inst.deb` won't
> install ./inst.deb. Instead, it'll install all packages that partially
> match regex `inst.deb`.
Yeah thanks, I remembered that just after posting.  But my issue 
remains,  I almost always want completion to stop trying to be clever 
and just give me local file completions.

and:

	Installing packages from local .deb files is not the task for apt-get.
	You should use `dpkg -i` instead.

Actually I know, but I just wanted to demonstrate the issue with completion and that showed the issue.


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

* Re: completion is over thinking things.
  2019-09-28 17:36   ` Ray Andrews
@ 2019-09-29  4:47     ` dana
  2019-09-29 15:29       ` Ray Andrews
  2019-09-29 13:09     ` Mikael Magnusson
  1 sibling, 1 reply; 13+ messages in thread
From: dana @ 2019-09-29  4:47 UTC (permalink / raw)
  To: Ray Andrews; +Cc: zsh-users

On 28 Sep 2019, at 12:36, Ray Andrews <rayandrews@eastlink.ca> wrote:
>But my issue remains,  I almost always want completion to stop trying to be
>clever and just give me local file completions.

A few people on IRC have file completion bound to a separate key sequence.
This is mentioned in the FAQ:

  http://zsh.sourceforge.net/FAQ/zshfaq04.html#l53

Alternatively, maybe you could use the fake or fake-always style to always add
files?

  zstyle -e ':completion:*' fake-always _files

That exact configuration seems like it would be irritating, though. Not sure
if there's a single style that would work 'nicely' in all cases

dana


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

* Re: completion is over thinking things.
  2019-09-28 17:36   ` Ray Andrews
  2019-09-29  4:47     ` dana
@ 2019-09-29 13:09     ` Mikael Magnusson
  2019-09-29 15:11       ` Ray Andrews
  1 sibling, 1 reply; 13+ messages in thread
From: Mikael Magnusson @ 2019-09-29 13:09 UTC (permalink / raw)
  To: Ray Andrews; +Cc: zsh-users

On 9/28/19, Ray Andrews <rayandrews@eastlink.ca> wrote:
> On 2019-09-28 10:13 a.m., Roman Perepelitsa wrote:
>> On Sat, Sep 28, 2019 at 7:06 PM Ray Andrews <rayandrews@eastlink.ca>
>> wrote:
>>>      $ ls inst.deb
>>>      inst.deb
>>>
>>>      $ apt-get install inst. [TAB]
>>>      Completing package
>>>      libapt-inst2.0
>>>      libmono-system-configuration-install4.0-cil
>>>      libmono-system-runtime-durableinstancing4.0-cil
>>>
>>> How can I get completion to stop looking and finding files God knows
>>> where and just expand filenames in the current directory?
>> This doesn't answer your question but `apt-get install inst.deb` won't
>> install ./inst.deb. Instead, it'll install all packages that partially
>> match regex `inst.deb`.
> Yeah thanks, I remembered that just after posting.  But my issue
> remains,  I almost always want completion to stop trying to be clever
> and just give me local file completions.
>
> and:
>
> 	Installing packages from local .deb files is not the task for apt-get.
> 	You should use `dpkg -i` instead.
>
> Actually I know, but I just wanted to demonstrate the issue with completion
> and that showed the issue.

Claiming that completion not completing invalid arguments for your
command is an "issue" seems pretty far fetched to me. If you always
want to complete files, don't run compinit in your startup files.

-- 
Mikael Magnusson

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

* Re: completion is over thinking things.
  2019-09-29 13:09     ` Mikael Magnusson
@ 2019-09-29 15:11       ` Ray Andrews
  2019-09-29 15:19         ` Pier Paolo Grassi
  0 siblings, 1 reply; 13+ messages in thread
From: Ray Andrews @ 2019-09-29 15:11 UTC (permalink / raw)
  To: zsh-users

On 2019-09-29 6:09 a.m., Mikael Magnusson wrote:
>
> Claiming that completion not completing invalid arguments for your
> command is an "issue" seems pretty far fetched to me. If you always
> want to complete files, don't run compinit in your startup files.
>
I appreciate the sophistication of that, but there are times when I 
really do want to complete on a filename even if it might seem like an 
invalid argument superficially.  I thought that compinit was the entire 
completion system!  Commenting it out and restarting, just as you say, I 
get 'dumb' file completions just as wanted.  Can we have it both ways?  
That is, tweak compinit so that perhaps on a final press of the TAB key 
it  will fall back to dumb file completion even if a kosher match has 
not been found?  Or some sort of temporary fallback to dumb completion?  
Most of the time it seems that file completion is all that's happening 
and anyway this sort of issue is very rare here, but short of restarting 
it would be nice to have dumb completion 'override' when wanted.  
Perhaps if a final press of TAB was used then instead of this:

Completing package

... we'd see:

Fallback to completing file

... or something like that.

I looked at zcompdump and there's nothing in there that looks 
promising.  I know that completion is the most inscrutable part of zsh, 
so I won't even attempt to understand it, and any tweak will be taken 
without question and on authority.  Or is there an approachable 
document?  Or some workaround?




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

* Re: completion is over thinking things.
  2019-09-29 15:11       ` Ray Andrews
@ 2019-09-29 15:19         ` Pier Paolo Grassi
  0 siblings, 0 replies; 13+ messages in thread
From: Pier Paolo Grassi @ 2019-09-29 15:19 UTC (permalink / raw)
  To: Ray Andrews; +Cc: zsh-users

[-- Attachment #1: Type: text/plain, Size: 1988 bytes --]

would it be enough a widget that does always filesystem completion
regardless of the command line so far, to be binded to a different-than-tab
shortcut?
that’s been my approach to the same problem, I also have special
only-directories and only-regular-files widgets too

Il giorno dom 29 set 2019 alle 17:12 Ray Andrews <rayandrews@eastlink.ca>
ha scritto:

> On 2019-09-29 6:09 a.m., Mikael Magnusson wrote:
> >
> > Claiming that completion not completing invalid arguments for your
> > command is an "issue" seems pretty far fetched to me. If you always
> > want to complete files, don't run compinit in your startup files.
> >
> I appreciate the sophistication of that, but there are times when I
> really do want to complete on a filename even if it might seem like an
> invalid argument superficially.  I thought that compinit was the entire
> completion system!  Commenting it out and restarting, just as you say, I
> get 'dumb' file completions just as wanted.  Can we have it both ways?
> That is, tweak compinit so that perhaps on a final press of the TAB key
> it  will fall back to dumb file completion even if a kosher match has
> not been found?  Or some sort of temporary fallback to dumb completion?
> Most of the time it seems that file completion is all that's happening
> and anyway this sort of issue is very rare here, but short of restarting
> it would be nice to have dumb completion 'override' when wanted.
> Perhaps if a final press of TAB was used then instead of this:
>
> Completing package
>
> ... we'd see:
>
> Fallback to completing file
>
> ... or something like that.
>
> I looked at zcompdump and there's nothing in there that looks
> promising.  I know that completion is the most inscrutable part of zsh,
> so I won't even attempt to understand it, and any tweak will be taken
> without question and on authority.  Or is there an approachable
> document?  Or some workaround?
>
>
>
> --
Pier Paolo Grassi

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

* Re: completion is over thinking things.
  2019-09-29  4:47     ` dana
@ 2019-09-29 15:29       ` Ray Andrews
  2019-09-29 16:44         ` Bart Schaefer
  0 siblings, 1 reply; 13+ messages in thread
From: Ray Andrews @ 2019-09-29 15:29 UTC (permalink / raw)
  To: zsh-users

On 2019-09-28 9:47 p.m., dana wrote:
>
>    http://zsh.sourceforge.net/FAQ/zshfaq04.html#l53
>
    [quote]

    If you simply want to try filename completion as a default when
    other completions fail, add it to the `|completer|' style for normal
    completion, for example:

         zstyle ':completion:*' completer _complete _ignored _files
       

    This adds filename completion to the end of the default types of
    completion. Your actual completer style may include other actions,
    such as expansion or approximate completion.

----------------------------------------

Thanks Dana, that's exactly what I'm thinking.  However I dare not cast 
such spells without some hand-holding.  Here's what I have now, and I 
have no idea how any of it works:

====================================
# allow approximate
# Original: zstyle ':completion:*' completer _complete _match _approximate
zstyle ':completion:*' completer _expand _complete
#Tab completion should be case-insensitive.
# Original: zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}'
zstyle ':completion:*' matcher-list '' 'm:{a-z}={A-Z}' 
'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=* l:|=*'
zstyle ':completion:*' auto-description 'specify: %d'
zstyle ':completion:*' format 'Completing %d'
zstyle ':completion:*' group-name ''
zstyle ':completion:*' list-colors ''
zstyle ':completion:*' list-prompt %SAt %p: Hit TAB 'for more', or the 
char to insert%s
###zstyle ':completion:*' menu select=2
### zstyle ':completion:*' menu select=long
zstyle ':completion:*' select-prompt %SScrolling active: current 
selection at %p%s
zstyle ':completion:*' use-compctl false
zstyle ':completion:*' verbose true

zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
zstyle ':completion:*:match:*' original only
zstyle ':completion:*:approximate:*' max-errors 1 numeric
zstyle ':completion:*:expand:*' tag-order all-expansions
# cd not select parent dir:
zstyle ':completion:*:cd:*' ignore-parents parent pwd

#Better completion for killall. Original:
zstyle ':completion:*:killall:*' command 'ps -u $USER -o cmd'
# tab completion for PID :D
zstyle ':completion:*:kill:*' force-list always
zstyle ':completion:*:kill:*' command 'ps -u $USER -o 
pid,%cpu,tty,cputime,cmd'
zstyle ':completion:*:*:kill:*' menu yes select
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) 
#([0-9]#)*=0=01;31'
=========================================

... probably half of that stuff is redundant or useless or harmful or 
whatever and I don't even know where it came from.  I'll take your edit 
on faith if you would be so kind.  Is there any way a mortal can get any 
sort of handle on any of that?  Genius borders on insanity.


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

* Re: completion is over thinking things.
  2019-09-29 15:29       ` Ray Andrews
@ 2019-09-29 16:44         ` Bart Schaefer
  2019-09-29 18:41           ` Ray Andrews
  0 siblings, 1 reply; 13+ messages in thread
From: Bart Schaefer @ 2019-09-29 16:44 UTC (permalink / raw)
  To: Ray Andrews; +Cc: Zsh Users

On Sun, Sep 29, 2019 at 8:30 AM Ray Andrews <rayandrews@eastlink.ca> wrote:
>
> ... probably half of that stuff is redundant or useless or harmful or
> whatever and I don't even know where it came from.

"I don't know half of you half as well as I should like, and I like
less than half of you half as well as you deserve."

Really though, there's nothing bad or alarming in there.  This is the
one you want to change:

> # Original: zstyle ':completion:*' completer _complete _match _approximate
> zstyle ':completion:*' completer _expand _complete

zstyle ':completion:*' completer _expand _complete _files

Note that this only makes completion fall back to _files when nothing
else matches; if _expand or _complete finds something, you won't get
file names.  If you want file names all the time, mixed in with other
results, you'll have to write a custom function.  The simplest such
function might look like:

_complete+files() {
  _alternative 'normal::_complete' 'files::_files'
}
zstyle ':completion:*' completer _expand _complete+files

I would not recommend doing this unless you also keep using the
display configuration below (specifically the group-name style),
otherwise the way things get mixed together will be too confusing.  As
written, this also has the drawback that even if _complete already
returns file names, _files will add them a second time anyway.

> # allow approximate
> #Tab completion should be case-insensitive.
> # Original: zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}'
> zstyle ':completion:*' matcher-list '' 'm:{a-z}={A-Z}'  'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=* l:|=*'

That's doing what the comment says, it makes completion
case-insensitive.  It also allows dots, underscores, and hyphens to
fill themselves in.

> zstyle ':completion:*' auto-description 'specify: %d'
> zstyle ':completion:*' format 'Completing %d'
> zstyle ':completion:*' group-name ''
> zstyle ':completion:*' list-colors ''
> zstyle ':completion:*' list-prompt %SAt %p: Hit TAB 'for more', or the char to insert%s
> zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s

Those are all about what the display looks like.

> zstyle ':completion:*' use-compctl false

That says not to fall back on the old built-in completions if the
compsys functions fail.

The rest of what you had is reasonably obvious, I think.  The
kill-specific styles are from a zsh-users post a few years ago.

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

* Re: completion is over thinking things.
  2019-09-29 16:44         ` Bart Schaefer
@ 2019-09-29 18:41           ` Ray Andrews
  2019-09-29 19:06             ` Bart Schaefer
  0 siblings, 1 reply; 13+ messages in thread
From: Ray Andrews @ 2019-09-29 18:41 UTC (permalink / raw)
  To: zsh-users

On 2019-09-29 9:44 a.m., Bart Schaefer wrote:
> On Sun, Sep 29, 2019 at 8:30 AM Ray Andrews <rayandrews@eastlink.ca> wrote:
>> "I don't know half of you half as well as I should like, and I like
>> less than half of you half as well as you deserve."
Bilbo.
>> zstyle ':completion:*' completer _expand _complete _files
>>
>> Note that this only makes completion fall back to _files when nothing
>> else matches; if _expand or _complete finds something, you won't get
>> file names.  If you want file names all the time, mixed in with other
>> results, you'll have to write a custom function.  The simplest such
>> function might look like:
Not to tempt the Gods, but if I changed the order:

zstyle ':completion:*' completer _files _expand _complete

... would I get files offered first?  I get the impression that that line is most of the meat of completion.

I would not recommend doing this

... Where angels fear to tread.  Praise, I'd not think of it. Normally I break things deliberately just to see how they work, and if it's out of bounds I'm going in ... but not here!

Thanks Bart and Dana.



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

* Re: completion is over thinking things.
  2019-09-29 18:41           ` Ray Andrews
@ 2019-09-29 19:06             ` Bart Schaefer
  2019-09-29 19:35               ` Ray Andrews
  0 siblings, 1 reply; 13+ messages in thread
From: Bart Schaefer @ 2019-09-29 19:06 UTC (permalink / raw)
  To: Ray Andrews; +Cc: Zsh Users

On Sun, Sep 29, 2019 at 11:42 AM Ray Andrews <rayandrews@eastlink.ca> wrote:
>
> Not to tempt the Gods, but if I changed the order:
>
> zstyle ':completion:*' completer _files _expand _complete
>
> ... would I get files offered first?

Yes, but in that case you'd rarely get the defined completions for the context.

Also you probably would want to keep _expand as the first function,
even if you swap the other two.

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

* Re: completion is over thinking things.
  2019-09-29 19:06             ` Bart Schaefer
@ 2019-09-29 19:35               ` Ray Andrews
  0 siblings, 0 replies; 13+ messages in thread
From: Ray Andrews @ 2019-09-29 19:35 UTC (permalink / raw)
  To: zsh-users

On 2019-09-29 12:06 p.m., Bart Schaefer wrote:
>
> Also you probably would want to keep _expand as the first function,
> even if you swap the other two.
>
Ok, I'll not mess with it.  What we've done really gives me exactly what 
I want: I can complete a long filename even when the context would 
suggest that it's not appropriate.


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

end of thread, back to index

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-28 17:05 completion is over thinking things Ray Andrews
2019-09-28 17:13 ` Roman Perepelitsa
2019-09-28 17:36   ` Ray Andrews
2019-09-29  4:47     ` dana
2019-09-29 15:29       ` Ray Andrews
2019-09-29 16:44         ` Bart Schaefer
2019-09-29 18:41           ` Ray Andrews
2019-09-29 19:06             ` Bart Schaefer
2019-09-29 19:35               ` Ray Andrews
2019-09-29 13:09     ` Mikael Magnusson
2019-09-29 15:11       ` Ray Andrews
2019-09-29 15:19         ` Pier Paolo Grassi
2019-09-28 17:14 ` gmail

zsh-users

Archives are clonable: git clone --mirror http://inbox.vuxu.org/zsh-users

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.zsh.users


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git