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 :verbose [option]?
?
Update:
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.
alias
then? oh wait, i see - you're talking about in the text editor. i think you want either: abbrev
or: map
. no - that's not it either. you want to know where it was defined? you could trygrep -l 'alias vi' ~/.*
to start. – mikeserv Dec 19 '15 at 07:39alias vi='vim'
locate. I want to delete that statement. That alias is really terrible. – Feng Yu Dec 19 '15 at 07:47grep
- it's almost definitely in one of your dot files in$HOME
- probably some~/.shellrc
or~/.profile
or~/.shenv
or something like that. thegrep
will spit out the file name. you could do:grep -n 'alias vi' ~/.* /dev/null
to ensure you get the whole matched line and the filenames and the line numbers for wherever it is matched. – mikeserv Dec 19 '15 at 07:49grep
my home directory, but noting print. And I don't want to grep root directory, that is awkard! – Feng Yu Dec 19 '15 at 07:55/etc
possibly inprofile
- though that would be weird - orbash/bashrc
orzsh/zshrc
or something. another way is to do:"$0" -vx
to get a printout of all of the commands read in when a new shell starts. – mikeserv Dec 19 '15 at 07:57echo $SHELL
) – Pandya Dec 19 '15 at 10:08.bashrc
,.bash_aliases
or at.bash_profile
right? – Pandya Dec 19 '15 at 10:13vi
<--vim
have done via alias. In deb-distro such operation is provided via update-alternatives – Costas Dec 19 '15 at 11:26type -a vi
to find out if there is an alias defined for vi. – Dec 20 '15 at 00:00