Saturday, May 4, 2024
9
rated 0 times [  9] [ 0]  / answers: 1 / hits: 18335  / 2 Years ago, wed, september 21, 2022, 5:36:57

When editing files like sudoers, I want to use emacs instead of nano. So I ran this command



sudo update-alternatives --config editor


And I selected emacs. The only issue is I like emacs in no window mode (the -nw flag) and I've aliased emacs as emacs='emacs -nw' so that I can use no window mode in normal use, but I don't know how to get my default editor to be in no window mode.



In other words, I need to get the command sudo visudo and similar commands that open up editors to open the file with emacs -nw. How can I do this? I'm on Ubuntu 12.04.


More From » default-programs

 Answers
4

Create a script that starts emacs with -nw flag, e.g. /usr/local/bin/emacs-nw.



#!/bin/sh

emacs -nw "$@"


Install it with update-alternatives --install.



sudo update-alternatives --install /usr/bin/editor editor /usr/local/bin/emacs-nw 2


Configure editor to be your new script.



sudo update-alternatives --set editor /usr/local/bin/emacs-nw

[#33378] Thursday, September 22, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
pantkie

Total Points: 209
Total Questions: 112
Total Answers: 138

Location: Venezuela
Member since Sat, Apr 24, 2021
3 Years ago
pantkie questions
Tue, Feb 14, 23, 07:17, 1 Year ago
Sat, May 8, 21, 05:13, 3 Years ago
Sat, Jun 11, 22, 17:14, 2 Years ago
Thu, Mar 10, 22, 12:32, 2 Years ago
;