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
511 stars 18 forks source link

Improved completions #128

Open Farid-NL opened 1 month ago

Farid-NL commented 1 month ago

Hi! :wave:

The main goal of this PR is to provide a list of abbreviations when calling the erase and rename commands.

There were other improvements I made a long the way though

Using double quotes only when necessary

Reasoning

Even though could be a performance improvement between using single or double quotes... this might be my OCD triggered.

Separate options from commands

Reasoning

Normally when pressing Tab you expect just the list of commands, but not the options i.e. --help. These will only show up when typing -Tab (for short and long flags) or --Tab (for long flags).

Demo

pr1

List abbreviations when using erase and rename commands

Reasoning

Maybe you don't use an abbreviation anymore, so instead of listing the abbreviations manually, an then type it into the erase or rename command, you can search for it wit the help of the completion system.

Features

Demo

pr2

Group related options and set exceptions when using a particular group

Reasoning

There could be multiple options for a specific context, for example:

So when one is chosen, the other options for the same context should not be shown.

Example: -S is used, then --session, -U and --user are not shown.

Demo

pr3

olets commented 1 month ago

Thanks for being game to talk this through and try different things.

Farid-NL commented 1 month ago

Thanks for being game to talk this through and try different things.

Glad I can help!

olets commented 1 month ago
Farid-NL commented 3 weeks ago

Sorry for the delay, some life related stuff.

I have a question regarding some examples to test

# for ' and "
abbr -S 'a"b"c'=d
abbr -S "a'b'c"=e

How would you normally erase/rename these abbreviations? What would you put exactly to erase/rename them?

I'm getting

abbr erase: No abbreviation `abc` found

or

abbr rename: No abbreviation `abc` found
olets commented 3 weeks ago

Sorry for the delay, some life related stuff.

No apologies necessary, take all the time you need.

How would you normally erase/rename these abbreviations?

Farid-NL commented 3 weeks ago

So, with that limitation in mind what would be the next steps to green light the PR?


Right now just certain characters (#118) doesn't seem to work in abbreviations, expansions with those characters work however (they are shown correctly in the completion's description).

# Display de completion properly the action (rename/erase) works.
abbr -S a:=b
abbr -S b=a:
abbr -S a="b="
abbr -S we="asd^asd\"hey\""
abbr -S wa="as\!hey"

# Display the completion properly but it won´t rename/erase it
abbr -S 'a"b"c'=d
abbr -S "a'b'c"=e
image