0

Where is the EDITOR environment variable initialized? so far I have checked the following files and could not find where it is:

  • ~/.bashrc
  • ~/.bash_profile
  • ~/.profile
  • /etc/profile
  • /etc/bashrc
  • /etc/environment
1
  • 1
    What do you mean by "originally"? By default it's not set at all. Commented Jun 11, 2022 at 12:12

2 Answers 2

1

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).

0

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .