environment-variableseditor

How do I permanently change $EDITOR to a specific text editor?


I am trying to work with crontabs, and cron never asked me which text editor I would like to use, and I don't like the choice it has taken.

To my surprise, when I run echo $EDITOR, I get a blank output.

I can change it with export EDITOR=/usr/bin/nano, so it is set for the session, but as soon as I log-out it doesn't retain the value.

I want it to be the system-wide default, so I can use it with all users, but adding EDITOR=/usr/bin/nano, which is the location of nano, to my /etc/environment, killing the terminal and relaunching still returns a blank line when running echo $EDITOR.

As @CHAOTING says down below, adding export EDITOR=/usr/bin/nanoto the .zshrc file in my home folder helped. Now, it is the default environmental variable for my user and for root, but running commands with sudo, I still get the wrong editor. Is there anyway the variable can be made trully global?

Any ideas what is going on and most importantly how I can set it up? Thank you in advance, everyone.


Solution

  • If you're using zsh, you can put export EDITOR='nano' inside ~/.zshrc. Zsh will automatically run this file. ( I think bash run ~/.bashrc as will )