MichaelAquilina / zsh-you-should-use

📎 ZSH plugin that reminds you to use existing aliases for commands you just typed
GNU General Public License v3.0
1.41k stars 44 forks source link

Feature request: interoperability with `zsh-abbr` #129

Open mainrs opened 8 months ago

mainrs commented 8 months ago

zsh-abbr allows for the creation of fish-like abbreviations. These get substituted in-shell with the specified command and do appear inside the history as the substituted command.

Repository: https://github.com/olets/zsh-abbr Related discussions: https://github.com/olets/zsh-abbr/discussions/51#discussioncomment-7354069

MichaelAquilina commented 1 month ago

this is a nice feature I was actually not even aware of, thanks for the suggestion :)

p1r473 commented 1 month ago

@mainrs Added in #133 I cant figure out how to detect whether an abbreviation was used though as it automatically gets swapped before the command is entered So it basically will always show up.

mainrs commented 1 month ago

@mainrs Added in #133 I cant figure out how to detect whether an abbreviation was used though as it automatically gets swapped before the command is entered So it basically will always show up.

Ahhh, I see what you mean. In fish (where I initially saw this), there seems to be a way to detect the raw user input . So it's possible to discern if the user used the abbreviation or the full command.

olets commented 1 month ago

Hi I'm the zsh-abbr maintainer 👋

Teaching zsh-you-should-use about zsh-abbr abbreviations is a neat idea.

@mainrs thanks for spearheading and middlemanning.

@p1r473 cool stuff in #133. I think it can be done with fewer or maybe even no forks (that is, external commands)! For example, you can get more robustly handle the quotation marks with Q or q parameter expansion modifiers (docs), and you can get the abbreviation directly, without building an inverted array, with the pattern ${(k)association_haystack[(r)$value_needle]} (r subscript flag docs). Would be great to support global abbreviations that aren't the entire line. Heads up that the upcoming "prefixes" feature will complicate things. (I don't know zsh-you-should-use well enough to comment on the limit and zstyle changes.)

@MichaelAquilina if you're up for supporting zsh-abbr abbreviations, I'm up for taking on the work of exporting some additional variables with an eye towards minimizing the implementation in zsh-you-should-use.

p1r473 commented 1 month ago

Hey long time @olets That would be great if you can add it in in a more official way :) Thanks for the tips. Ive tried to incorporate them into my pull request now. Here's a visual example of how its working now showing an abbreviation for ls -t as list image

MichaelAquilina commented 1 month ago

@olets that sounds great! :) thanks for chiming in. Any variables that could serve as an "API" to zsh-abbr would be very helpful in making sure this feature works correctly and doesnt take a lot of effort to maintain.

What kind of variables do you have in mind?

olets commented 1 month ago

What kind of variables do you have in mind?

One each for

If no opportunity to use an abbreviation was missed, they'd all be empty.