olets / zsh-abbr

The zsh manager for auto-expanding abbreviations, inspired by fish. ~13,000 unique cloners as of May '24, 580+ Homebrew installs 6/23-6/24
https://zsh-abbr.olets.dev
Other
517 stars 18 forks source link

String should only expand words anchored to the left? #7

Closed philwhln closed 4 years ago

philwhln commented 4 years ago

I'm finding that zsh-abbr is expanding words found within the command.

For instance, in fish shell I had abbrs for "master" and "pods", but not I can't use these words in other commands.

Typing "pods" expands to "kubectl get pods", but if I press the up arrow to re-run, it expands to "kubectl get kubectl get pods", which then fails.

Instead, should the expansion only happen for the first word in the string, which I think it what fish does.

olets commented 4 years ago

Reasonable expectation coming from fish, but this is intentional. You can work around it by appending a space to the expansion:

abbr -e pods[ctrl-space][enter]
abbr pods kubectl get pods\[space][enter]
pods[enter] # expands to `kubectl get pods ` and accepts
[up arrow, `!!`, etc] # `kubectl get pods `

But good news! It's changing soon. v3 will distinguish between regular (ie left-anchored) and anywhere-on-the-line abbreviations, just like zsh's alias / alias -g. As with zsh's alias, left-anchored / fish-abbr-like will be default.

Aiming to release 3.0.0 in the next week and a half 🤞

philwhln commented 4 years ago

Aiming to release 3.0.0 in the next week and a half 🤞

Awesome! 👏

olets commented 4 years ago

3.0.0 is up! Won't have much spare time this week but let me know if you have problems.

philwhln commented 4 years ago

Thanks! Tested my kubectl get pods issues and works great 👍

olets commented 4 years ago

Glad to hear to hear it

olets commented 2 months ago

Belatedly recognizing bug reporters in https://github.com/olets/zsh-abbr#community and https://zsh-abbr.olets.dev/community/. would you like to be added @philwhln?