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

2 new features: "you used", and support for abbreviations #131

Closed p1r473 closed 1 month ago

p1r473 commented 1 month ago

Hey, really cool project you have here Ive added 2 new features

  1. Support for abbreviations (e.g. zsh-abbr)
  2. Ability to show what alias you just used is aliased to (more like a "you used" opposite of "you should use" in case you forget you keep using aliases

Can be disabled easily with

zstyle ':you-should-use:' you_should_use_alias_enabled false zstyle ':you-should-use:' you_used_alias_enabled false zstyle ':you-should-use:*' you_should_use_abbreviation_enabled false

image

p1r473 commented 1 month ago

I will try to tackle the tests tomorrow :) closing until it's ready

MichaelAquilina commented 1 month ago

Hi @p1r473 thanks for the contribution :) I like the feature but I would say it should be disabled by default as it would cause everyone's setup to suddenly change if they upgraded.

Using zstyle as way of using options is actually something I've been meaning to migrate to for a while no (instead of using env variables which is actually quite hacky).

I might try and find an existing migration path to move there before introducing zstyle first though. Better to consistently use all zstyle rather than use some env and some zstyle options

p1r473 commented 1 month ago

image In this example, I have abbr list='ls -t1' and alias cat='ccat'

Id like to implement 2 styles for abbreviation, same as what was done for alias "you should use abbreviation" and "you used abbreviation" I cant figure out how to detect whether an abbreviation was used though as it automatically gets swapped before the command is entered If anyone can help me figure that out!

MichaelAquilina commented 1 month ago

@p1r473 in terms of the two features, lets keep them as two separate PRs so I can review them individually and not let one block the other. For example, I think abbreviations is a no brainer to add, but I am still weighing whether adding the "you used" feature would be worth maintaining in terms of additional complexity.

I dont know enough about zsh abbreviations but if I have some time I'll give them a look and see what I can find out. It might be that hooks are too late in the process to be able to catch these changes depending on how abbreviations are implemented internally.

p1r473 commented 1 month ago

Sure I will split them up

The reason I think it's very important is because oftentimes you use an alias without remembering you did and then you wonder why things don't work, especially if you alias very common things like ls or rm.

Example, I recently aliased ls to eza, and found that ls -t works, but eza -t required a flag, and this broke a bunch of my scripts. Its more a reminder you used an alias.

I am happy to maintain the you-used part