Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: interoperability with zsh-abbr #129

Open
mainrs opened this issue Oct 23, 2023 · 7 comments
Open

Feature request: interoperability with zsh-abbr #129

mainrs opened this issue Oct 23, 2023 · 7 comments

Comments

@mainrs
Copy link

mainrs commented Oct 23, 2023

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: olets/zsh-abbr#51 (reply in thread)

@MichaelAquilina
Copy link
Owner

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

@p1r473
Copy link
Contributor

p1r473 commented May 16, 2024

@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
Copy link
Author

mainrs commented May 16, 2024

@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
Copy link

olets commented May 29, 2024

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
Copy link
Contributor

p1r473 commented May 29, 2024

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
Copy link
Owner

@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
Copy link

olets commented May 30, 2024

What kind of variables do you have in mind?

One each for

  • the text you could have abbreviated
  • the abbreviation you could have used
  • the abbreviation you could have used's scope
  • the abbreviation you could have used's type
  • and, after prefix support is released, the prefix (if any)

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants