Here are my personal aliases for editing root owned files:
# CLI superuser nano; compiled; version 2.8.0
function sunano {
export SUDO_EDITOR='/usr/local/bin/nano'
sudoedit "$@"
}
# GUI superuser xed; packaged; version 1.2.2
function suxed {
export SUDO_EDITOR='/usr/bin/xed'
sudoedit "$@"
}
# GUI superuser sublime-text; packaged; version 3126
function susubl {
export SUDO_EDITOR='/opt/sublime_text/sublime_text -w'
sudoedit "$@"
}
Let me take it from end:
Sublime Text works great now thanks to Stephen Kitt's advice.
Xed seems to work good too, it shows that the privileges are elevated, which I personally don't like to be reminded of, but there seems to be no problem with it, colors are there and it didn't even need some wait switch like Sublime.
The problem I have is with Nano as follows:
If I invoke it as I was used to, e.g.:
sudo nano /etc/nanorc
The colors are there.
But if I call it with the new alias:
sunano /etc/nanorc
There are no colors whatsoever.
The configuration seems to have been read though, because it looks the same as I've configured it.
EDIT1: Apparently this issue affects at minimum the config file:
-rw-r--r-- 1 root root 8.6K Apr 8 02:30 /etc/nanorc
Other files, e.g. Bash or C++ are colored, I'm confused.