Where is the EDITOR environment variable initialized? so far I have checked the following files and could not find where it is:
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
Nowhere. You are thinking about it from a wrong perspective.
Each application has its own preferred editor (or pager, or whatever else it needs). That is built in into application. Defined at compile time and never changes.
If creator of application wants to allow user to change it later - then an application can take a look at environment variable EDITOR, PAGER, etc and use whatever user defined there.
Some applications with capability to switch to a user preferred editor do not look at environment variable EDITOR, but at its own configuration files. Or both (
git for example).
I'm going to guess that $EDITOR is set in your current shell but you are not sure how and where it got set? If that's the case, and you are on a system with
strace installed like Linux you may want to try to look at all the files that BASH for instance opens. I modified the answer in this question slightly Find out what scripts are being run by bash at login
echo exit | strace -e open bash -li
From the BASH man page:
-i If the -i option is present, the shell is interactive. -l Make bash act as if it had been invoked as a login shell (see INVOCATION below).
Another way, in another comment from that answer is to invoke bash with the
-x flag enabling echo of each command that is executed:
/bin/bash -x -l -i -c 'exit' 2>&1 | less
I would do this first to make sure that $EDITOR is somehow even being set on startup and not exported by some other script or program you are running after your shell has already initialized.