zsh-users
 help / color / mirror / code / Atom feed
* Statistics and completions
@ 2020-12-05 13:21 A. Wik
  2020-12-05 21:20 ` Bart Schaefer
  0 siblings, 1 reply; 4+ messages in thread
From: A. Wik @ 2020-12-05 13:21 UTC (permalink / raw)
  To: zsh-users

Hi all,

I am wondering how hard it would be to implement the collection of
statistics about commands (or other parameters, such as filename
arguments) you run most frequently (or never), and to use these stats
to guide the priority of listed completions.  This feature could be
"seeded" from a history file to get started.

Cheers,
Albert.


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

* Re: Statistics and completions
  2020-12-05 13:21 Statistics and completions A. Wik
@ 2020-12-05 21:20 ` Bart Schaefer
  2020-12-05 23:16   ` Felipe Contreras
  0 siblings, 1 reply; 4+ messages in thread
From: Bart Schaefer @ 2020-12-05 21:20 UTC (permalink / raw)
  To: A. Wik; +Cc: Zsh Users

On Sat, Dec 5, 2020 at 5:22 AM A. Wik <awik32@gmail.com> wrote:
>
> I am wondering how hard it would be to implement the collection of
> statistics [...]
> to guide the priority of listed completions.

I would approach that as follows:

Require the zsh/db/gdbm module to be available (incidentally there is
a generic API for database modules if anybody wants to work on other
backends).

In the database, store a mapping from zstyle contexts to group-order
lists.  How to populate that mapping is up to you; it could probably
be updated via comppostfuncs.  I don't have any good ideas how to
prepopulate it from a history file (particularly if one uses
histignorealldups, as that would skew the frequencies).

At shell startup, evaluate a set of zstyle commands constructed from
the keys of the database, using "zstyle -e" to dynamically fetch the
latest value from the entry whenever the style is looked up.  One
generic style might be devised to create new keys for previously
unused contexts.


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

* Re: Statistics and completions
  2020-12-05 21:20 ` Bart Schaefer
@ 2020-12-05 23:16   ` Felipe Contreras
  2020-12-06  1:58     ` Bart Schaefer
  0 siblings, 1 reply; 4+ messages in thread
From: Felipe Contreras @ 2020-12-05 23:16 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: A. Wik, Zsh Users

On Sat, Dec 5, 2020 at 3:21 PM Bart Schaefer <schaefer@brasslantern.com> wrote:
>
> I don't have any good ideas how to
> prepopulate it from a history file (particularly if one uses
> histignorealldups, as that would skew the frequencies).

I use a separate history file and add my own zshaddhistory function to
unconditionally add every single command typed there.

-- 
Felipe Contreras


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

* Re: Statistics and completions
  2020-12-05 23:16   ` Felipe Contreras
@ 2020-12-06  1:58     ` Bart Schaefer
  0 siblings, 0 replies; 4+ messages in thread
From: Bart Schaefer @ 2020-12-06  1:58 UTC (permalink / raw)
  To: Felipe Contreras; +Cc: A. Wik, Zsh Users

On Sat, Dec 5, 2020 at 3:16 PM Felipe Contreras
<felipe.contreras@gmail.com> wrote:
>
> I use a separate history file and add my own zshaddhistory function to
> unconditionally add every single command typed there.

Sure, but that doesn't help with knowing what parts of the command
were generated by completion, or what contexts to use to store the
stats.


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

end of thread, other threads:[~2020-12-06  1:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-05 13:21 Statistics and completions A. Wik
2020-12-05 21:20 ` Bart Schaefer
2020-12-05 23:16   ` Felipe Contreras
2020-12-06  1:58     ` Bart Schaefer

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).