2

There are two ways to change the default editor:

  • update-alternatives --set editor /bin/nano
  • export EDITOR='/bin/nano'
    added to ~/.bashrc (single user) or /etc/profile.d/ (all users)

Is there any difference / nuance between them? e.g. availability on multiple distros?


UPDATE

There is also select-editor

5
  • 2
    What is the big picture, the final goal? Why do you want to set the default editor for bash users on most systems, but not for users of other shells?
    – Philippos
    Sep 18, 2019 at 10:31
  • 1
    Why not both? set EDITOR=editor and configure the alternatives to point to whatever real editor. Covers most bases.
    – muru
    Sep 18, 2019 at 10:41
  • @muru What is editor? Is that just a symlink to something defined by `update-alternatives" tool?
    – lonix
    Sep 18, 2019 at 10:49
  • @Philippos I've removed that bit to avoid going off topic. I concede your point.
    – lonix
    Sep 18, 2019 at 10:50
  • 1
    Well, yes, editor is a symlink.
    – muru
    Sep 18, 2019 at 11:16

1 Answer 1

2
  • update-alternatives is specific to debian
  • Changing a users .bashrc is a bad idea. Your users will hate you.
  • Writing a file to /etc/profile.d/ will not affect users of ksh, csh, zsh...
    any settings made in the users .bashrc will overwrite your setting. Which is a good thing.

If update-alternatives is available on the target system, that's the way to go. It should be available on both debian- and redhat-distros.

Otherwise /etc/profile.d/ is probably your best option. But you will need to look in other places to configure the not-bash shells.

0

You must log in to answer this question.

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