I had this same challenge when setting up my new MacBook Pro.
Here's how I solved it
To switch to your editor of choice (say nano) on a MacBook you will need to add the following lines to your ~/.zshrc
file if your default shell is zsh
or ~/.bash_profile
if your default shell is bash
:
export EDITOR=nano
export VISUAL="$EDITOR"
However, a simpler approach to do this will be to use the echo
command to insert them into your ~/.zshrc
file if your default shell is zsh
:
echo 'export EDITOR=nano' >> ~/.zshrc
echo 'export VISUAL="$EDITOR"' >> ~/.zshrc
OR ~/.bashrc
if your default shell is bash
:
echo 'export EDITOR=nano' >> ~/.bash_profile
echo 'export VISUAL="$EDITOR"' >> ~/.bash_profile
Run the command below to activate the new configuration:
source ~/.zshrc
Or
source ~/.bash_profile
If you need to switch to other editors of choice you can replace nano
with your preferred editor:
That's all.