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.46k stars 43 forks source link

Print to stdout can mess plugins #27

Closed selfish closed 6 years ago

selfish commented 6 years ago

Best use case: zsh plugin git which we all use cannot complete branch names, because it does git branch --all, and the output from you-should-use will mess the output.

If there was a way to test current context and know if the user didn't type in the command, the text can be hidden.

MichaelAquilina commented 6 years ago

I wasnt ware of this actually. I will try fix it as soon as I get the chance. Thanks for reporting the issue @selfish

MichaelAquilina commented 6 years ago

@selfish I am trying to find a reproducible test case to check that #28 correctly fixes this issue. Would you mind providing me with your:

Alternatively, you can checkout my branch and install it to your system to see if it works :)

selfish commented 6 years ago

@MichaelAquilina sure, no problem, thanks for the help! Sorry for not including the steps to reproduce, here they are:

  1. Have any alias that will trigger upon git branch. Example: I use alias g='git'.
  2. Have the default oh-my-zsh git plugin enabled: plugins=(git ...) or antigen bundle git or however you do it.
  3. Start your terminal, make sure zsh is up to date (save and start a new terminal, or type in exec zsh to re-source your .zshrc)
  4. Navigate to a directory that is a git repository.
  5. Type in git checkout and the beginning of the name of a branch, for example: git checkout ma, assuming you have master branch. In any other scenario, the git plugin will show auto-completion for the branch name, but when YSU is active, it will fail to parse the format.

The reason being that it types git branch, and hits the Found existing alias prompt.

Expected behavior (YSU turned off): image

Actual behavior: zsh autocomplete shows, listing files in the directory.

Since I do not have a clean environment to test this in an isolated way, I can't rule out the option that this has to do with other stuff on my machine. If you can't reproduce it, I'm happy to try and assist.

selfish commented 6 years ago

Oh, NICE. Thank you so much!

MichaelAquilina commented 6 years ago

Please test that this works @selfish and get back to me :) I was uable to reproduce it myself unfurtunately but the output should be writtent to stderr now

selfish commented 6 years ago

Seems to be looking good. Thanks again!

MichaelAquilina commented 6 years ago

No problem, glad to be of help :)