This question already has an answer here:
This is an
alias defined in my Linux shell:
$ alias vi alias vi='vim'
This alias is so stupid that I want to delete it definitely.
Is there a command to find where
alias vi='vim' might have been defined? Something like Vim's
After hours of search, I found that
alias vi=vim is located in
/etc/profile.d/vim.sh, which is sourced by
/etc/bashrc, which is sourced by
.etc/.bashrc, which is sourced by
~/.bash_profile. Such a long journey!
Though I have located
alias vi=vim, There is still a question:
Is there an easier way to do this? Is there a way that answer these question: Is alias defined through the command line, a script file, or something else? If defined in a script file, which file it is?
The method used above is "brute-force search". There maybe a dozen files that sourced by
~/.bash_profile. It is so inefficient that it spent me hours to debug.