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

Some shorter aliases are not detected #79

Open
1 of 4 tasks
benwaffle opened this issue Aug 6, 2019 · 13 comments
Open
1 of 4 tasks

Some shorter aliases are not detected #79

benwaffle opened this issue Aug 6, 2019 · 13 comments

Comments

@benwaffle
Copy link
Contributor

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

  1. Make sure oh-my-zsh is installed
  2. Run gd --word-diff
  3. 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.

@MichaelAquilina
Copy link
Owner

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?

@MichaelAquilina
Copy link
Owner

MichaelAquilina commented Oct 7, 2019

@benwaffle polite ping about this (I can't seem to reproduce this)

@MichaelAquilina
Copy link
Owner

@benwaffle take a look at the latest release (1.5.0). The issue should be fixed there. Thanks for reporting the issue!

@MichaelAquilina
Copy link
Owner

Re-opening this issue as the feature that solved it has been reverted.

@Aloxaf
Copy link

Aloxaf commented Dec 25, 2019

Emmm, why the fix was reverted?

@MichaelAquilina
Copy link
Owner

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.

@NightMachinery
Copy link

@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'}"
}

@MDHD-Yee
Copy link

MDHD-Yee commented Jun 18, 2020

@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"

@spotlesscoder
Copy link

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

@Arcitec
Copy link

Arcitec commented Dec 16, 2021

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.

@MichaelAquilina
Copy link
Owner

MichaelAquilina commented Dec 16, 2021

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

@Arcitec
Copy link

Arcitec commented Dec 16, 2021

@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". :)

@olets
Copy link

olets commented Oct 23, 2023

This might be helpful https://unix.stackexchange.com/a/482492

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

No branches or pull requests

8 participants