I’m using .bash. For whatever reason, it doesn’t detect aliases!
This bit me on the ass recently: a party who shall remain nameless had the default grep aliased:
alias grep='grep -i'
Yuck.
So when I searched for some debugging info, I got thousands of lines of false positives. Very bad.But when I did a “which grep” it just told be the location of the executable. Not that it was aliased. So it looked like my grep (bash on debian) was broken!
What I wanted for which is:
- if there is an alias, display the alias
- if not, display the path of the executable
So the magic command to make which behave like it should is:
alias which='alias | /usr/bin/which --read-alias'Just kidding. What that does is “crash your bash.” Who knows why. Crebbs told me that’s what it was (so much for nameless) and I almost locked myself out of my computer. Turns out the “magic” command is simply
type
which is built in to bash. Gah!