You are not logged in.
Pages: 1
Topic closed
Does anyone know how to set the default editor for systemctl edit?
The man page implies that you should set it in the systemctl Environment. However I have tried setting both the VISUAL and EDITOR environment variables with systemctl set-environment VISUAL=<my editor> and neither seems to have any effect. I have confirmed that the variables are set with systemctl show-environment, however no matter what I do whenever I run systemctl edit <daemon unit> it always defaults to GNU nano.
Anyone have any luck with this? I can't find anything that can explain this online or in the man pages.
Offline
I set my environment variables in .zshenv or .profile and systemctl picks this up and opens service files in Vim when I use the edit command.
This is consistent with the man page:
$SYSTEMD_EDITOR
Editor to use when editing units; overrides $EDITOR and $VISUAL. If neither $SYSTEMD_EDITOR nor $EDITOR nor $VISUAL are present or if it is set
to an empty string or if their execution failed, systemctl will try to execute well known editors in this order: nano(1), vim(1), vi(1).
Offline
Thanks for the quick reply.
I have tried setting it with the shell
export SYSTEMD_EDITOR="emacs -nw"
And it still default to vim.
I tried putting it my .bashrc as well, which should have the exact same effect as far as I know, and still defaulted to GNU nano.
Offline
Add this to your .profile (or .bash_profile if that is what you use):
export SYSTEMD_EDITOR="emacs -nw"
and log out/in or just source the file.
Offline
I copied and pasted your `export` command above and can confirm it behaves as expected. I can't explain why you're not seeing the same behaviour, sorry.
Are you familiar with our Forum Rules, and How To Ask Questions The Smart Way?
BlueHackers // fscanary // resticctl
Offline
These are the exact commands I am running, with output
$ export SYSTEMD_EDITOR="emacs -nw"
$ sudo -E echo $SYSTEMD_EDITOR # Outputs "emacs -nw"
emacs -nw
$ sudo systemctl set-environment SYSTEMD_EDITOR="$(which emacs)"
$ sudo systemctl show-environment
LANG=en_US.UTF-8
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
SYSTEMD_EDITOR=/usr/bin/emacs
sudo -E systemctl edit docker # starts GNU nano
Offline
I must have something screwed up...I just don't know what it is. I am seeing this behaviour on multiple systems, even after clean installs.
Offline
Try this in your .profile:
export EDITOR="/usr/bin/emacs"
export FCEDIT="$EDITOR"
export VISUAL="$EDITOR"
export SUDO_EDITOR="$EDITOR"
Offline
Still Nano...
$ . .profile
$ sudo -E systemctl edit docker # Still GNU Nano
$ printenv | grep emacs # Just to be sure...
SYSTEMD_EDITOR=emacs -nw
EDITOR=/usr/bin/emacs
FCEDIT=/usr/bin/emacs
SUDO_EDITOR=/usr/bin/emacs
VISUAL=/usr/bin/emacs
Offline
How is your sudoers configured? Not all user env variables carry over, you have to explicitly state that you want them to pass to root's session: https://wiki.archlinux.org/index.php/Su … _variables
Edit: just noticed you're using -E, oh well.
Last edited by WorMzy (2015-05-19 07:43:41)
Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD
Making lemonade from lemons since 2015.
Offline
I was able to solve this by adding
Defaults env_keep += "EDITOR"
to /etc/sudoers
Offline
Thanks for sharing, uberushaximus. I'm going to take this opportunity to close this old thread now.
Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD
Making lemonade from lemons since 2015.
Offline
Pages: 1
Topic closed