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

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

Closed
wants to merge 13 commits into from

Conversation

p1r473
Copy link

@p1r473 p1r473 commented May 10, 2024

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

p1r473 commented May 10, 2024

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

@MichaelAquilina
Copy link
Owner

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 p1r473 reopened this May 13, 2024
@p1r473 p1r473 closed this May 13, 2024
@p1r473 p1r473 reopened this May 13, 2024
@p1r473 p1r473 closed this May 13, 2024
Copy link
Author

@p1r473 p1r473 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @MichaelAquilina thanks for the feedback
Ive indeed disabled them by default

local limit="${1:-9000000000000000}"
local limit="${1:-$HISTSIZE}"

-this made sense to me but you should sanity check it

@p1r473 p1r473 reopened this May 13, 2024
@p1r473
Copy link
Author

p1r473 commented May 13, 2024

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

MichaelAquilina commented May 16, 2024

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

p1r473 commented May 16, 2024

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

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

Successfully merging this pull request may close these issues.

None yet

2 participants