For anyone who may stumble across this old question ...
There is one thing that I think needs to be addressed.
~/.nanorc
is used to apply your user specific settings to nano, so if you are editing files that require the use of sudo nano
for permissions then this is not going to work.
When using sudo
your custom user configuration files will not be loaded when opening a program, as you are not running the program from your account so none of your configuration changes in ~/.nanorc
will be applied.
If this is the situation you find yourself in (wanting to run sudo nano
and use your own config settings) then you have three options :
sudo nano
/root/.nanorc
file/etc/nanorc
global config fileKeep in mind that /etc/nanorc
is a global configuration file and as such it affects all users, which may or may not be a problem depending on whether you have a multi-user system.
Also, user config files will override the global one, so if you were to edit /etc/nanorc
and ~/.nanorc
with different settings, when you run nano
it will load the settings from ~/.nanorc
but if you run sudo nano
then it will load the settings from /etc/nanorc
.
Same goes for /root/.nanorc
this will override /etc/nanorc
when running sudo nano
Using flags is probably the best option unless you have a lot of options.