Say I have:
>which -a foo
/bin/foo
/usr/bin/foo
I want something like:
>foo
Warning: multiple foo in PATH
... foo gets executed ...
This functionality would have saved me really really lots of time today.
I should have guessed this is happening earlier but the problem was unclear
to me at the beggining and I started to dig in quite opposite direction.
Well, you can do it, but it is not so easy as you may think.
First, you need to create a function that will check
all directories in the PATH, and look there for the command you try to run.
Then you need to bind this function to the DEBUG trap of your current shell.
I wrote a small script that does that:
Example of usage: