Some shorter aliases are not detected
benwaffle opened this issue · 13 comments
Issue Details
Please provide the following details when opening an issue:
Operating System (uname -a)
Darwin MacBook-Pro 18.6.0 Darwin Kernel Version 18.6.0: Thu Apr 25 23:16:27 PDT 2019; root:xnu-4903.261.4~2/RELEASE_X86_64 x86_64
zsh version (zsh --version)
zsh 5.7.1 (x86_64-apple-darwin18.2.0)
you-should-use version (echo "$YSU_VERSION")
1.3.0
How is zsh-you-should-use installed?
- zplug
- oh-my-zsh
- Antigen
- Other (please specify)
Steps to reproduce the issue
- Make sure oh-my-zsh is installed
- Run
gd --word-diff
- See that
gdw
is not recommended
Based on alias gd='git diff'
and alias gdw='git diff --word-diff'
, I think that running gd --word-diff
should recommend gdw
.
I'm afraid this issue went past my radar without me noticing! Would you please mind posting your alias definitions to see if I can easily reproduce the issue on my machine?
@benwaffle polite ping about this (I can't seem to reproduce this)
@benwaffle take a look at the latest release (1.5.0). The issue should be fixed there. Thanks for reporting the issue!
Re-opening this issue as the feature that solved it has been reverted.
Emmm, why the fix was reverted?
The way the feature was implemented introduced a number of bugs. This problem is actually a lot harder than it looks to solve and will require quite a bit of thinking.
@MichaelAquilina Can you check out how https://github.com/djui/alias-tips solves this? (Search for Disable Command Expansion
on that page)
I use this little function to expand aliases, can't it solve this?
expand-aliases () {
# 'See https://unix.stackexchange.com/questions/372811/better-understand-a-function-expanding-aliases-in-zsh'
unset 'functions[_expand-aliases]'
functions[_expand-aliases]="$@"
(($+functions[_expand-aliases])) && print -r -- "${functions[_expand-aliases]#$'\t'}"
}
@MichaelAquilina Besides, sometimes if there exist multiple aliases for the same command, this plugin can not find the shortest one.
$ alias abc=abcd ab=abcd
$ abcd
Found existing alias for "abcd". You should use: "abc"
$ alias abc=abcd ab=abcd a=abcd
$ abcd
Found existing alias for "abcd". You should use: "a"
The first one should be "ab"
Also for me an issue
In my .zshrc I have
alias cd..="cd .."
alias ..="cd .."
Result:
user@pc ~ cd ..
Found existing alias for "cd ..". You should use: "cd.."
user@pc /home
I would have expected the suggestion of using the shorter ..
alias
https://github.com/djui/alias-tips is a bad solution. It literally boots up a Python interpreter every time you run a shell command, lol. It's terrible!
zsh-you-should-use is much better, because it's just a fast, minimalistic, pure zsh script.
But perhaps some of its algorithms can be ported to Zsh, because alias-tips is good at finding the shortest matching alias.
Writing in python is lot easier than writing zsh scripts I says this with python as my main daily language :)
Some of those algorithms might require quite a bit of work as a result. But I'd be happy for someone to try give it a go. Alternatively you can also wait for me to have the time to do it, but I cant make any promises in terms of when
@MichaelAquilina Totally understandable. Actually, I am very happy with your plugin now, when I discovered export YSU_MODE=ALL
which lets me see every alias! :) It's enough for me because it prints every matching alias, instead of attempting to pick some arbitrary "best match". :)
This might be helpful https://unix.stackexchange.com/a/482492