First of all, a function can be defined without the function
keyword so a better search would be
grep 'cp()' .*
That will search through files such as .zshrc
and .profile
and whatnot. If that finds nothing, you might also want to see the various files loaded by zsh
. These are listed at the very end of man zsh
:
FILES
$ZDOTDIR/.zshenv
$ZDOTDIR/.zprofile
$ZDOTDIR/.zshrc
$ZDOTDIR/.zlogin
$ZDOTDIR/.zlogout
${TMPPREFIX}* (default is /tmp/zsh*)
/etc/zsh/zshenv
/etc/zsh/zprofile
/etc/zsh/zshrc
/etc/zsh/zlogin
/etc/zsh/zlogout (installation-specific - /etc is the default)
By default $ZDOTDIR
should be your $HOME
. So, this command should find your offending file:
grep 'cp()\|cp ()' ~/.zshenv ~/.zprofile ~/.zshrc ~/.zlogin /etc/zsh/zshenv \
/etc/zsh/zprofile /etc/zsh/zshrc /etc/zsh/zlogin
I added the \|
since you can also have spaces between the function name and the function itself. Finally, @Dennis points out that the parentheses can also be omitted if you use the function
keyword. So, to be even more safe, do this:
grep -E 'function cp|cp *\(\)' ~/.zshenv ~/.zprofile ~/.zshrc ~/.zlogin \
/etc/zsh/zshenv /etc/zsh/zprofile /etc/zsh/zshrc /etc/zsh/zlogin
grep
will not search for files beginning with a.
so it is pretty much useless. That's not true. When used with the-r
switch, grep will go trough all files in directories it encounters. (At least my version of grep does.) – Dennis – 2014-01-26T22:16:13.047@Dennis I stand corrected, I was thinking of globbing which is completely irrelevant here. Thanks, answer corrected. – terdon – 2014-01-26T22:19:11.803
Also, the parentheses are optional if the
function
keyword is used.grep -E 'function cp|cp *\(\)'
should catch all cases. – Dennis – 2014-01-26T22:24:58.690@Dennis fair enough, thanks again, answer edited. – terdon – 2014-01-26T22:26:19.007