fran-f / keypirinha-terminal-profiles

A plugin to integrate Keypirinha and Windows Terminal
MIT License
18 stars 1 forks source link

Make selections appear in KeyPirinha history #10

Closed MaddyGuthridge closed 1 year ago

MaddyGuthridge commented 3 years ago

Currently, choices using this package aren't stored in KeyPirinha's history, which means that the options will never change order based on usage. For example, I want the input ps to open PowerShell in Windows Terminal, but it is about the 50th result when I give that input. With most app launches, the input and the choice it maps to is stored in KeyPirinha's history, so that when the same input is given, previous choices with that input can be prioritised. Basically, it'd really improve my life if the entries for this extension were stored in KeyPirinha's history.

fran-f commented 3 years ago

Hello Miguel! Unfortunately my plugin has no control on the ordering and the recency algorithm used by Keypirinha.

As far as I understand, the program scores the first letter of words higher, the contiguous letters closer to the start of the item name. So if you type ps, there will be many other entries with a higher score than "Windows Terminal: PowerShell". In terms of recency instead, Keypirinha uses different ordering scores for different queries. So if you type powershell and choose the Terminal profile, that does not raise the same item for different queries, such as ps or ever powershe.

I do find that behaviour a bit annoying 🤔 I think I unconsciously work around it by using wt as a prefix, for example wtp for PowerShell, or wtu for my Ubuntu WSL shell.

Sorry, nothing I can do from this side!

MaddyGuthridge commented 3 years ago

I'm not so much talking about the initial ordering. As well as it's initial sorting of values, KeyPirinha prioritises results if they've appeared recently in the history with that input. As such, including choices related to your package in KeyPirinha's history would greatly improve the rankings in search after the profiles had been used a few times.

I'm not familiar enough with KeyPirinha to get this to work myself, but I know it works as this works for things like the Windows Apps plugin. It should just be a matter of finding out how that plugin includes values in KeyPirinha's history and using the same logic.

fran-f commented 3 years ago

I see, I'll have a look at that plugin and come back to you then. There's plenty I don't know about the Keypirinha API 🙂

fran-f commented 3 years ago

Double checked WindowsApps' code (see on_execute) and Keypirinha's documentation, and I can't see a way to programmatically affect historical ordering.

As I mentioned before, I believe this is done automatically and for all items by Keypiriniha itself. And it currently works with this plugin as well, when I use "stronger" shortcuts. If I type bash, and run my "Windows Terminal: Bash" profile, the next time I type bash the same item appears at the top of the results. Only for bash though, not ba or bas.

Unfortunately ps does not score high against what I believe are Keypirinha's ordering criteria: word initials, and contiguous letters. However, it took me one try to teach the launcher that wps should show "Windows Terminal: Powershell" at the top of the list.