djui / alias-tips

An oh-my-zsh plugin to help remembering those aliases you defined once
781 stars 51 forks source link

Do not tip when using another alias of the same command #24

Closed gilmrjc closed 8 years ago

gilmrjc commented 8 years ago

If two or more aliases are used for the same command, alias-tip gives me the other alias as tip.

djui commented 8 years ago

To understand correctly: You mean having alias f=foo and alias fo=foo gives tip f.

Could you define "other"? It sound like you get an unexpected result. You expect maybe both f & fo as tips?

gilmrjc commented 8 years ago

The bc command has 2 aliases: "calc" and "=". When I use = I get the following:

$ = 5+5
Alias tip: calc 5+5
10

But "=" is not a command, is an alias.

I expect to get an alias tip when calling the command, but no when calling another alias of the same command

djui commented 8 years ago

How did you manage to make = an alias? Could you post the output of alias here, please? bc 5+5 gives me File 5+5 is unavailable..

gilmrjc commented 8 years ago

The plugin I'm using (https://github.com/arzzen/calc.plugin.zsh) do this:

# bc - An arbitrary precision calculator language
function = 
{
  echo "$@" | bc -l
}

alias calc="="

About this:

calc should not have been suggested as alias tip, because it's longer than the actual command, here =.

I get tips even if they are longer than the actual command. Is this another bug?

$ sudo whoami
Alias tip: please whoami
root
djui commented 8 years ago

OK, that clarifies a bit. So = is not an alias, it's a function. Alias-tips currently does not consider functions any special to programs, as it's hard argue that all functions are entirely different from programs.

I could imagine consider a flag to introduce Do not offer aliases for functions.

djui commented 8 years ago

@gilmrjc Could you try https://github.com/djui/alias-tips/pull/25 (tests currently don't pass and need to be updated)

gilmrjc commented 8 years ago

Yes, it works fine now :smiley:

$ = 5+5
10