how to find file defining an alias
zsh -x 2>zsh.trace
exit
grep 'alias.*subl' zsh.trace
The -x
option causes zsh to print out every command that it executes on stderr. Any command that was executed from reading a file has a prefix with the file name and line. So look for the alias definition in the trace file and you'll know where it was defined.
Related videos on Youtube
Ali Samii
Team leader in managing the development team for my company on a strategic level. I'm a novice programmer with a lot of enthusiasm and a desire to become better.
Updated on September 18, 2022Comments
-
Ali Samii over 1 year
I am having a problem I'm not sure how to get around.
Somehwhere on my system, I have an alias defined as such:
alias subl=\''/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl'\'
I am not sure what file this is in, and I want to change (or actually remove) it.
I could just unalias it in my .zshrc, but that's not as elegant a solution.
When I run
alias | grep subl
it shows me the alias. Is there a way for me to have it also echo the path to the file defining the alias?Thanks
-
mikeserv over 9 yearsI think that if there is something inelegant here it is probably that you have so many shell configuration files that you do not know where they are. No offense or anything, but.... maybe do without that oh your zsh - that' a behemoth man.
-
mikeserv over 9 yearsanyway, maybe try
grep -R 'alias subl...'
-
-
mikeserv over 9 yearsClever. But even if it helps him here, there probably isn't a big enough bandaid for the source of this problem.' Though, in honesty, reading through the file that produces might be something of a wakeup call, too.