How can I find out where an alias is defined on my system? I am referring to the kind of alias that is used within a Terminal session launched from Mac OS X (10.6.3).
For example, if I enter the alias
command with no parameters at a Terminal command prompt, I get a list of aliases that I have set, for example:
alias mysql='/usr/local/mysql/bin/mysql'
However, I have searched all over my system using Spotlight and mdfind
in various startup files and so far can not find where this alias has been defined. ( I did it a long time ago and didn't write down where I assigned the alias).
A Bash alias is a method of supplementing or overriding Bash commands with new ones. Bash aliases make it easy for users to customize their experience in a POSIX terminal. They are often defined in $HOME/. bashrc or $HOME/bash_aliases (which must be loaded by $HOME/.
How to Quickly Access & Show Original from an Alias in Mac OS. You also can select an alias and then hit Command + R to quickly jump the original item in the Finder as well, or you can right-click and choose “Show Original” from the contextual menu, use whichever method is fastest for you.
Aliases allow you to define new commands by substituting a string for the first token of a simple command. They are typically placed in the ~/. bashrc (bash) or ~/. tcshrc (tcsh) startup files so that they are available to interactive subshells.
You can see a list of defined aliases on your profile by simply executing alias command.
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 la la: aliased to ls -lAh cweekly:~$ 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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With