Changing default editor- `update-alternatives` not working

Hi-

I’m trying to change the default editor away from nano to vim.

Trying this:

gloria|john ➜ / sudo update-alternatives --config editor
There are 3 choices for the alternative editor (providing /usr/bin/editor).

  Selection    Path               Priority   Status
------------------------------------------------------------
* 0            /bin/nano           40        auto mode
  1            /bin/nano           40        manual mode
  2            /usr/bin/mcedit     25        manual mode
  3            /usr/bin/vim.tiny   15        manual mode

Press <enter> to keep the current choice[*], or type selection number: 3
update-alternatives: using /usr/bin/vim.tiny to provide /usr/bin/editor (editor) in manual mode
update-alternatives: error: unable to remove '/usr/share/man/da/man1/editor.1.gz.dpkg-tmp': Read-only file system

I assume this is failing due to the Read-only file system discussed in the thread that has this suggestion to

You can re-enable r/w on the rootfs without installing the dev tools by running:

sudo /usr/local/libexec/disable-rootfs-protection

Bear in mind there is no enable-rootfs-protection - we recommend backing up your configuration before enabling this.

But… I don’t really want to disable-rootfs-protection if this is the problem.

Does anyone know of an -ahem- alternative to update-alternatives, or another way to change the default editor?

Cheers
John

Edit ~/.zshrc to add EDITOR=vim.tiny.

Doesn’t work- at least for what I would like it to work for.

Have EDITOR set in my env

gloria|john ➜ / env|grep EDITOR
EDITOR=/usr/bin/vim
gloria|john ➜ / editor

After editor, nano pops up when I would expect vim. Same for jlmkr edit docker.

What prompted me to look for this is running jlmkr edit docker - I want it to open vim instead of nano. Searching the web led me to update-alternatives (after trying to set $EDITOR- sorry, I should have mentioned I had tried that already).

Cheers
John

Funny. Because $EDITOR support was specifically added to jailmaker way back in v1.3

1 Like

Thanks both. I guess the problem was the sudo part of my jlmkr alias.

Using -E to pass through environment variables to sudo works:

gloria|john ➜ / env|grep EDITOR
EDITOR=/usr/bin/vim
gloria|john ➜ / sudo -E '/mnt/a/jailmaker/jlmkr.py' edit docker

brings up vim for me.

2 Likes

@Jip-Hop should the recommended alias shrortcut be updated to pass -E?

Updated the readme. Thanks for letting me know!

2 Likes