I have spent sometime trying to figure out how to change the default editor in Midnight Commander. I am running XFCE most of the time on Fedora 19
I have tried suggestions from Googling including exporting EDITOR in $HOME/bashrc...running select-editor ( doesn't appear to be on Fedora )and creating a .select_editor text file in HOME. None have worked so far.
If I open a terminal first then m-c loads the proper editor...but if I call m-c from a desktop file which loads a terminal, then loads m-c with the -e option then vi is loaded.
I am missing something.
On Wed, May 14, 2014 at 01:52:11PM -0400, Frank McCormick wrote:
I have tried suggestions from Googling including exporting EDITOR in $HOME/bashrc...running select-editor ( doesn't appear to be on Fedora )and creating a .select_editor text file in HOME. None have worked so far.
If I open a terminal first then m-c loads the proper editor...but if I call m-c from a desktop file which loads a terminal, then loads m-c with the -e option then vi is loaded.
When you open a terminal and run mc yourself, bash is run in interactive mode. Whereas using the desktop file is not. Since you set the value of EDITOR in ~/.bashrc, only the interactive knows about it (see the "Invocation" section in man bash). All environment variable related setup should go in ~/.bash_profile. If you use multiple kinds of sh-like shells, it should be ~/.profile. This way your whole session inherits the environment.
Hope this helps,
On 15/05/14 05:32 AM, Suvayu Ali wrote:
On Wed, May 14, 2014 at 01:52:11PM -0400, Frank McCormick wrote:
I have tried suggestions from Googling including exporting EDITOR in $HOME/bashrc...running select-editor ( doesn't appear to be on Fedora )and creating a .select_editor text file in HOME. None have worked so far.
If I open a terminal first then m-c loads the proper editor...but if I call m-c from a desktop file which loads a terminal, then loads m-c with the -e option then vi is loaded.
When you open a terminal and run mc yourself, bash is run in interactive mode. Whereas using the desktop file is not. Since you set the value of EDITOR in ~/.bashrc, only the interactive knows about it (see the "Invocation" section in man bash). All environment variable related setup should go in ~/.bash_profile. If you use multiple kinds of sh-like shells, it should be ~/.profile. This way your whole session inherits the environment.
Hope this helps,
Putting it in ~/.profile (which didn't exist before) works. Thanks for the help
On Wed, 14 May 2014 13:52:11 -0400, Frank McCormick wrote:
I have spent sometime trying to figure out how to change the default editor in Midnight Commander. I am running XFCE most of the time on Fedora 19
I have tried suggestions from Googling including exporting EDITOR in $HOME/bashrc...running select-editor ( doesn't appear to be on Fedora )and creating a .select_editor text file in HOME. None have worked so far.
If I open a terminal first then m-c loads the proper editor...but if I call m-c from a desktop file which loads a terminal, then loads m-c with the -e option then vi is loaded.
I am missing something.
First of all, it's "mc" ("man mc") or "MC" (as pointed out in the README). ;)
Disabling "use internal edit" in mc's menu and setting $EDITOR works for me. Obviously, this can only work if the environment is kept intact and not deleted prior to executing programs. Some terminals and tools don't pass on the user's environment variables when executing programs. If you make your desktop file not run mc but a script or another terminal, does echo $EDITOR still show your customized setting?
On 15/05/14 05:38 AM, Michael Schwendt wrote:
On Wed, 14 May 2014 13:52:11 -0400, Frank McCormick wrote:
I have spent sometime trying to figure out how to change the default editor in Midnight Commander. I am running XFCE most of the time on Fedora 19
I have tried suggestions from Googling including exporting EDITOR in $HOME/bashrc...running select-editor ( doesn't appear to be on Fedora )and creating a .select_editor text file in HOME. None have worked so far.
If I open a terminal first then m-c loads the proper editor...but if I call m-c from a desktop file which loads a terminal, then loads m-c with the -e option then vi is loaded.
I am missing something.
First of all, it's "mc" ("man mc") or "MC" (as pointed out in the README). ;)
Disabling "use internal edit" in mc's menu and setting $EDITOR works for me. Obviously, this can only work if the environment is kept intact and not deleted prior to executing programs. Some terminals and tools don't pass on the user's environment variables when executing programs. If you make your desktop file not run mc but a script or another terminal, does echo $EDITOR still show your customized setting?
It used to work when the desktop file ran a script consisting of (xterm -e mc) but stopped working when it ran xterm -e mc. Another user suggested exporting EDITOR in ~/.profile, which works. Of course EDITOR is now exported in ~/.bash_profile, ~/.bashrc and ~/.profile. So I guess ~/.profile is the place it belongs in this case.
On Thu, 15 May 2014 09:26:12 -0400, Frank McCormick wrote:
It used to work when the desktop file ran a script consisting of (xterm -e mc) but stopped working when it ran xterm -e mc. Another user suggested exporting EDITOR in ~/.profile, which works. Of course EDITOR is now exported in ~/.bash_profile, ~/.bashrc and ~/.profile. So I guess ~/.profile is the place it belongs in this case.
From man bash:
When bash is invoked as an interactive login shell, or as a non-inter‐ active shell with the --login option, it first reads and executes com‐ mands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable. The --noprofile option may be used when the shell is started to inhibit this behavior.
On Thu, May 15, 2014 at 04:54:35PM +0200, Michael Schwendt wrote:
On Thu, 15 May 2014 09:26:12 -0400, Frank McCormick wrote:
It used to work when the desktop file ran a script consisting of (xterm -e mc) but stopped working when it ran xterm -e mc. Another user suggested exporting EDITOR in ~/.profile, which works. Of course EDITOR is now exported in ~/.bash_profile, ~/.bashrc and ~/.profile. So I guess ~/.profile is the place it belongs in this case.
From man bash:
When bash is invoked as an interactive login shell, or as a non-inter‐ active shell with the --login option, it first reads and executes com‐ mands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable. The --noprofile option may be used when the shell is started to inhibit this behavior.
The key is to realise it inherits the environment from the parent login shell (bash --login).