How to find out where alias (in the bash sense) is defined when running Terminal in Mac OS X How to find out where alias (in the bash sense) is defined when running Terminal in Mac OS X bash bash

How to find out where alias (in the bash sense) is defined when running Terminal in Mac OS X


For OSX, this 2-step sequence worked well for me, in locating an alias I'd created long ago and couldn't locate in expected place (~/.zshrc).

cweekly:~ $ which lala: aliased to ls -lAhcweekly:~$ grep -r ' ls -lAh' ~/Users/cweekly//.oh-my-zsh/lib/aliases.zsh:alias la='ls -lAh'

Aha! "Hiding" in ~/.oh-my-zsh/lib/aliases.zsh. I had poked around a bit in .oh-my-zsh but had overlooked lib/aliases.zsh.


you can just simply type in alias on the command prompt to see what aliases you have. Otherwise, you can do a find on the most common places where aliases are defined, eg

grep -RHi "alias" /etc /root


First use the following commands

List all functions

functions 

List all aliases

alias 

If you aren't finding the alias or function consider a more aggressive searching method

Bash version

bash -ixlc : 2>&1 | grep thingToSearchHere

Zsh version

zsh -ixc : 2>&1 | grep thingToSearchHere

Brief Explanation of Options

-i     Force shell to be interactive.-c     Take the first argument as a command to execute-x      -- equivalent to --xtrace-l      Make bash act as if invoked as a login shell