1

On a fresh ranger install I tried to open neofetch config with ranger and selected ed to see what is it. I am glad Ctrl+D worked to exit the ed, but now ranger opens all files with it. Restarting terminal didn't work. ~/.config/ranger is empty:

$ ls -la .config/ranger/
total 12
drwxr-xr-x  2 techtonik techtonik 4096 ліс 24 23:32 .
drwx------ 24 techtonik techtonik 4096 ліс 24 22:19 ..
-rw-r--r--  1 techtonik techtonik   35 ліс 24 23:32 bookmarks
-rw-r--r--  1 techtonik techtonik    0 ліс 24 23:32 history
-rw-r--r--  1 techtonik techtonik    0 ліс  7 14:03 tagged

How to fix that?

UPD: $EDITOR is empty, rifle still runs the ed.

$ rifle -l ~/.config/neofetch/config.conf 
0:editor::$EDITOR -- "$@"
1:pager::"$PAGER" -- "$@"
$ echo $EDITOR

$ rifle ~/.config/neofetch/config.conf 
13949

UPD2: Ubuntu 18.10

UPD3: I don't see that ed is selected by OS

$ update-alternatives --display editor
editor - auto mode
  link best version is /bin/nano
  link currently points to /bin/nano
  link editor is /usr/bin/editor
  slave editor.1.gz is /usr/share/man/man1/editor.1.gz
  slave editor.fr.1.gz is /usr/share/man/fr/man1/editor.1.gz
  slave editor.it.1.gz is /usr/share/man/it/man1/editor.1.gz
  slave editor.ja.1.gz is /usr/share/man/ja/man1/editor.1.gz
  slave editor.pl.1.gz is /usr/share/man/pl/man1/editor.1.gz
  slave editor.ru.1.gz is /usr/share/man/ru/man1/editor.1.gz
/bin/ed - priority -100
  slave editor.1.gz: /usr/share/man/man1/ed.1.gz
/bin/nano - priority 40
  slave editor.1.gz: /usr/share/man/man1/nano.1.gz
/usr/bin/vim.basic - priority 30
  slave editor.1.gz: /usr/share/man/man1/vim.1.gz
  slave editor.fr.1.gz: /usr/share/man/fr/man1/vim.1.gz
  slave editor.it.1.gz: /usr/share/man/it/man1/vim.1.gz
  slave editor.ja.1.gz: /usr/share/man/ja/man1/vim.1.gz
  slave editor.pl.1.gz: /usr/share/man/pl/man1/vim.1.gz
  slave editor.ru.1.gz: /usr/share/man/ru/man1/vim.1.gz
/usr/bin/vim.tiny - priority 15
  slave editor.1.gz: /usr/share/man/man1/vim.1.gz
  slave editor.fr.1.gz: /usr/share/man/fr/man1/vim.1.gz
  slave editor.it.1.gz: /usr/share/man/it/man1/vim.1.gz
  slave editor.ja.1.gz: /usr/share/man/ja/man1/vim.1.gz
  slave editor.pl.1.gz: /usr/share/man/pl/man1/vim.1.gz
  slave editor.ru.1.gz: /usr/share/man/ru/man1/vim.1.gz
  • 2
    Ed, man! !man ed – dessert Nov 24 '18 at 21:23
  • 1
    Did you try running it as e.g. EDITOR=vim ranger? – dessert Nov 24 '18 at 21:29
  • Oh, I am sure it will invoke vim as expected. However, I want to know where ranger stores the ed setting. – anatoly techtonik Nov 24 '18 at 21:31
  • It is an enviromental VAR set in the OS/SHELL/WHATEVER other than in ranger itself. global – Michael Prokopec Nov 24 '18 at 21:33
  • @dessert You know your stuff too. – Michael Prokopec Nov 24 '18 at 21:39
1

As pointed out by @toon in ranger tracker, ranger doesn't provide any editor selection dialogs if EDITOR is not set. It resorts to hardcoded vim, but Debian/Ubuntu hackers patch ranger to use sensible-editor, which is a bash script that is not connected with updates-alternatives in any way, and stores editor choice in ~/.selected_editor:

$ cat ~/.selected_editor 
# Generated by /usr/bin/select-editor
SELECTED_EDITOR="/bin/ed"

I guess this sensible-editor bash script was implemented as a hack, because update-alternatives works on a system level, and users without root needed to edit bash config to select their EDITOR (which doesn't work for everyone).

Instead of implicitly patching ranger, the Debian folks could explicitly set EDITOR=sensible-editor for user level sessions. "Explicit is better than implicit". At least this way we won't spend so much time here. Digging man I found that sensible-editor is explained in this policy page:

If it is very hard to adapt a program to make use of the EDITOR or PAGER variables, that program may be configured to use /usr/bin/sensible-editor and /usr/bin/sensible-pager as the editor or pager program respectively.

And according to this text, ranger should not be patched, because it is already aware and makes use of EDITOR.


Closing this with final rants, why the ed is given as the user-level choice of Linux editor in 2018 ???..

0

Check what editor, the os itself is pointing at. I think, ranger is looking at the now default for the os. Change the os's perfered editor, and I think it will change rangers.

sudo update-alternatives --config editor

Type the number of the one you want and hit enter.

In your case

auto mode

/bin/ed - priority -100

Each alternative has a priority associated with it. When a link group is in automatic mode, the alternatives pointed to by members of the group will be those which have the highest priority.

Set priority to 10

Change that and you should be good.

  • I updated the question that I am using Ubuntu 18.10. I have no idea how to check what editor Ubuntu is pointing at. – anatoly techtonik Nov 24 '18 at 21:01
  • Updated the question to show that ed is probably not selected as default OS editor by update-alternatives. – anatoly techtonik Nov 24 '18 at 21:11
  • /bin/ed - priority -100 – Michael Prokopec Nov 24 '18 at 21:16
  • -100 means it should be selected last, after nano (40) and vim (30). If I run editor ~/.config/neofetch/config.conf the nano is opened. – anatoly techtonik Nov 24 '18 at 21:18
  • Ok, humor me and change it to 10. Tell me what happens. – Michael Prokopec Nov 24 '18 at 21:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.