How to reset vim and neovim when sourcing wrong file .zshrc instead of init.vim - macos

I'm using macOS Catalina which has built in Vim 8.1. I'm also using iTerm with zsh and oh-my-zsh. I installed neovim for my personal use and when I setting it up, I accidentally enter source .zshrc in Command mode instead of source init.vim. From then, when I open neovim or built in vim, it does not source init.vim anymore and shows error message like below:
Error detected while processing VIMINIT:
E33: No previous substitute regular expression
Press ENTER or type command to continue
There is a line in my .zshrc that exports VIMINIT variable
export VIMINIT="~/.config/nvim/init.vim"
How can I undo this or is there any other way to reset vim to original setting? Thank you so much

I tried #Niloct solution, unset VIMINIT and vim/neovim is backed to normal. After that, I reopen the iTerm and it showed error message again. Therefore I removed the export line from .zshrc and the problem has been solved.

To load a clean neovim:
nvim -u NONE -U NONE -N -i NONE
Actually I have an alias for that
alias vinone='nvim -u NONE -U NONE -N -i NONE'
This way you can type vinone and use your default neovim

Related

Backspace Not Working on VS Code's Bash Terminal

So, I'm new to VS code just installed it and I'm having an issue. The backspace doesn't work in the bash terminal of VS code. The backspace works on the cmd terminal of VS code though.
Not working means when I tap the backspace it prints a white space in the terminal.
Also the backspace key works perfectly fine on Git Bash
I tried googling but didn't find what I was looking for!
Please help.
You can check your TERM by running echo $TERM, but before you do this I suggest you restart your vscode as you have already set the TERM by using the command. I think your TERM was set to something incompatible.
export TERM=xterm will set the emulator to xterm.
Most application will expect that you already have the emulator set to something compatible such as xterm or linux.
For more information regarding what export TERM=xterm does you can check the following answer
Now, if you restart your vscode or terminal inside the vscode, TERM will reset to default and the problem will occur again. Therefore I suggest you add the export TERM=xterm in bash_profile or bashrc.
To add it to bashrc, type following in your terminal:
echo export TERM=xterm >> ~/.bashrc
source ~/.bashrc
go to command palette and select open shortcut key words go to this file and delete all data in this file

Set up path on prompt on pycharm terminal windon

I just upgrade pycharm into 2016.3.1. Before upgrade, I do not have problem to see the current directory path under the prompt on terminal window. After upgrade into pycharm 2016
3.1. All directory path on prompt on terminal window seems like messed up with 133;C;133;D;01337;RemoteHost=hawkins#pc_name.home1337;CurrentDir=/Users/hawkins/path133;MAC:path hawkins$ 133;B for some reason. Anyone have expereience on how to resolve this?
MAC:path$
133;C;133;D;01337;RemoteHost=hawkins#pc_name.home1337;CurrentDir=/Users/hawkins/path133;MAC:path hawkins$ 133;B
133;C;133;D;01337;RemoteHost=hawkins#pc_name.home1337;CurrentDir=/Users/hawkins/path133;MAC:path hawkins$ 133;B
133;C;133;D;01337;RemoteHost=hawkins#pc_name.home1337;CurrentDir=/Users/hawkins/path133;MAC:path hawkins$ 133;B
I had a similar problem. It turned out my problem was due to have iTerm shell integration installed.
As you have tagged the question [osx], I assume that you might also have done this.
There is a nice explanation to what these strange symbols mean in this answer: https://unix.stackexchange.com/a/294886/47407
I figured I could avoid having to uninstall Shell Integration by clearing my PROMT_COMMAND, and setting PS1 again. I made a shell script called pycharm_terminal.sh with the following
export PROMT_COMMAND=
export PS1="\[\e[31m\]\u\[\e[0m\] at \[\e[33m\]\h\[\e[0m\] in \[\e[32m\]\w\[\e[0m\] at [\A] \[\033[31m\]`git branch 2> /dev/null | grep -e ^* | sed -E s/^\\\\\*\ \(.+\)$/\(\\\\\1\)\ /`\[\033[35m\]\n$ \[\033[00m\]"
bash -i
The PS1 variable can be set to whatever you had before. This is just how I like mine.
Now, in PyCharm Settings: Go to Tools > Terminal and in "Shell path" set it to /bin/bash <path_to_pycharm_terminal.sh>.
Now try opening a new terminal in PyCharm. It shouldn't have those control character errors.
Solution that worked for me:
Go to Settings > Plugins
Find plugin "Python Terminal" and disable it
Restart PyCharm
The only negative effect I've noticed - auto activation of virtualenv on terminal start doesn't work.
for some reason, I figure it out by create a .pycharmrc under by user directories
and setting up /usr/local/bin/bash --rcfile ~/.pycharmrc under Tool->Terminal on shell path. It seems like it fixed but i have no idea why
MAC: path$ cat ~/.pycharmrc
exec bash
This is what worked for me:
Created new file pycharm_terminal.sh with one command bash -l
Then I set PyCharm Settings: to Tools > Terminal and in "Shell path" set it to /bin/bash/path_to_pycharm_terminal.sh.
Restart PyCharm and all work as expected
bash -l, by man, is a: -l Make bash act as if it had been invoked as a login shell (see INVOCATION below).
which is probably mean, that when PyCharm starts the Terminal and executing the pycharm_terminal.sh with bash -l, everything in .bash_profile is include by default
Found this question while trying to resolve similar issue for 'Geany' on mac osx. I had an install of iterm2 on my machine and was getting garbage in front of the terminal prompt.
similar solution as KPLauritzen offered also works for 'Geany' terminal as such.
Hope this helps someone:
Create shell script in home directory using desired PS1 & CLICOLOR settings:
~/geany_terminal.sh
export PROMT_COMMAND=
export PS1='[\e[1;32m][\u#\h \W] \D{%F %T}\n\$[\e[0m]'
export CLICOLOR=1
export LSCOLORS=gxBxhxDxfxhxhxhxhxcxcx
bash -i
Then I went to 'Edit -> Preferences --> Terminal' and set my 'Shell' to:
/bin/bash /Users/myusername/geany_terminal.sh
Upon reloading Geany, the Terminal now displays with PS1 and CLICOLOR settings exactly as I have set in my .bash_profile without garbage in front.
You can just activate your .bash_profile
/bin/bash --rcfile ~/.bash_profile

I have to type export PATH=~/anaconda/bin:"$PATH" everytime I rerun the terminal

I have installed the Anaconda for Mac, but there is something wrong with me:
when I type the commandwhich conda or which ipython, I get conda not found and ipython not find
Then I find this command export PATH=~/anaconda/bin:"$PATH" works for me. It solves the problem above, but everytime I rerun the terminal the problem is still there, I have to type it again.
so I want to find a way to solve the problem fundamentally
I have tried to add it into the ~/.bashrc, ~/.profile, ~/.bash_profile, but these don't work for me.
Try this in .bash_profile
export PATH="$HOME/anaconda/bin:$PATH"
Then try launching a new terminal and running:
echo $PATH
The output should start with /anaconda/bin:
If that still doesn't work... A work around might be to invoke bash after running terminal i.e. type "bash". Which should cause bash to launch with .bash_profile
I run on MacOs Catalina 10.15 and this did the trick for me:
shell is zsh !
$ source /Users/myprofilename/anaconda3/bin/activate
then
$ conda init zsh
the new anaconda documentation also highlights this:
Make sure you're not using ZShell or another form of a shell. If the case you'd have to add the path to your respective shell file, e.g .zshrc.
sudo xed /etc/environment
after open this archive add :/home/youruser/anaconda3/bin
If you're using ZShell follow the steps below:
In your terminal type open ~/.zshrc
Add the following to the file export PATH=/opt/homebrew/bin:$PATH
Save your file and then run the following command source ~/.zshrc
Please note that the homebrew path on Apple silicon is /opt/homebrew/bin

Basic command lines on Mac terminal not working

I changed the bash profile while trying to install mongodb and none of my command lines are working on terminal. I read online that I need to fix the $PATH but I can't even access it when none of my commands are working.
Help?
Mistakenly I also ran into same problem where to resolve this I had to reset my PATH variable to basic settings as below :
export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin"
Once you set PATH variable now you can open the .bash_profile file in same terminal session only and make changes accordingly. This will resolve your problem.
Ok I found the answer from here:
"Open Terminal, and go to File (or Shell) -> New Command. Type in open -e .profile (or substitute some other file instead of .profile), and hit Run. That should open TextEdit with the file you want to fix; you can remove the offending lines there."
in my case i typed in nano .bash_profile and that allowed me to edit my bash profile and fix the issue.
can't use terminal from error in .bash_profile
Run this in terminal:
export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"

In Mac OSX 10.5, it can't find my Terminal commands sudo, find, etc

I don't know what has happened, but in my Terminal on Mac OSX 10.5 it can no longer find my sudo command, or find command, etc. They are there because if I put /usr/bin/sudo or /usr/bin/find it works fine...
My .bash_login file looks like this:
export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/bin$PATH"
My .bash_profile file looks like this:
export PATH="/Library/Frameworks/Python.framework/Versions/Current/bin:/Library/Python/2.5/site-packages/django_trunk/django/bin:/usr/local/mysql/bin:/usr/bin/sudo$PATH"
I'll say now, I don't really know what I'm doing with the Terminal. I'm just a beginner to it all, and I must of done something for the environment variables (is that what they're called?) to be lost. I presumed I'd just have to make sure the /usr/bin/ path is in my bash files, but they are, and it doesn't seem to work. Please help!
Also, when I do use the /usr/bin/find command, it says "Permission denied" to me, even though I am logged into Mac OSX as the System Administrator account. I don't understand.
Any help would be grand. Thank you - James
It looks like both of your PATH exports are malformed:
export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/bin$PATH"
The end bit there won't work. It should be:
export PATH=/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/bin:$PATH
Notice the colon before '$PATH'? It's important ;)
Also, the double quotes are not necessary.
If this doesn't work, we will need more information. It is possible that something else is modifying your path even after your shell configurations are loaded.
Can you post the results of:
$ echo $PATH
Configuration files are not always a good indication of the current environment variables, since they are modified by many programs and files, all across your system. To see all of your environment variables, you can run:
$ env
This should fix the problem completely and permanently.
first, export environment paths by using below command in the terminal.
export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/b‌​in
now you have the commands you want. (eg. try ls. You'll see the command is working). But this is only for the current session. If you close the terminal and open a new one, you will have the previous issue. To make this change permanent, use below command,
go to home directory
cd ~
open .bash_profile file in nano / vim (I'm using nano here)
nano .bash_profile
This will open up nano editor. In a new line, paste the following;
export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:$PATH
press 'control'+'o' to save (WriteOut) and 'control'+'x' to exit nano.
All done ! Now try the commands.
Check out --- http://www.sweeting.org/mark/blog/2008/05/26/mac-os-x-tip-setting-path-environment-variables
I went trough the same issue and here is how I solved it.
First of all I reverted the file to its original doing this way
/usr/bin/nano ~/.bash_profile
In my case I was not able to make work any command alias. Even vi or vim didnt work without specifying the full path of that command.
If nano is not installed just replace nano in the command by the editor installed
After that just restart the computer. In my case as I said bellow I could not use any command. When trying to do /usr/bin/source ~/.bash_profile
that command failed. So I had to restart the OS and it worked

Resources