When opening terminal, this line shows every time:
-bash: :wq: command not found
How can I stop it from appearing every time Terminal opens ?
It looks like there exists a line :wq
in one of your shell’s profile files, such as ~/.bash_profile
, which was probably added as a failed attempt at quitting Vim when editing such a file.
To edit the bash profile with TextEdit, run open -e ~/.bash_profile
in Terminal. Edit the file to remove the :wq
line only. Save it, quit TextEdit and restart Terminal to see changes. You might want to make a copy of the file in case you're worried: cp ~/.bash_profile ~/.bash_profile.bak
.
If you don’t want to use Terminal at all, see this answer How to add the PATH for mysql bin on Mac? with instructions on how to edit a profile file only using GUI.
source .bashrc
which should re-source the file, and even give you the error again in case you haven't yet fixed it (IIRC anyway)
Commented
Nov 13, 2019 at 22:07
.bashrc
, which could cause weird problems. Opening a new terminal will usually lead to a cleaner state.
Commented
Nov 14, 2019 at 5:11
You messed up when editing .bash_profile with the 'vi' editor aka 'vim'.
You did your writing in insert mode, then when you finished, you were supposed to hit esc
to exit insert mode, then : w q
for command, write and quit.
You failed to hit esc
so it inserted :wq as additional text. You then collected yourself, tried esc : w q
one more time, and that worked.
Fire up vim one more time, opening the file as before.
esc
but do it anyway. It may beep. :wq
cat ~/.bash_profile
orcat ~/.bashrc
and paste it here.sed -i '/:wq/d' ~/.bash*
should fix it ;)