You are not logged in.

#1 2009-09-21 19:11:55

iamsmrt
Member
Registered: 2009-08-12
Posts: 138

Making nano the global editor (including root user)?

Vi isn't my strong suit so I decided to make nano my global editor by editing my /etc/profile file. However, whenever I do something like 'sudo crontab -e', it still opens it in vi, how can I force it to open in nano?

EDIT: I didn't really mind vi for edting before but I updated my system yesterday and the behavior of it's changed for some reason. Before I was able to use the arrow keys to navigate text files, even in insert mode but now, it inserts characters when I try to use the arrow keys in insert mode. So to edit the files, I have to enter insert mode, do the editing that I want in one location, exit insert mode, move onto the next location, etc. It's really annoying, that's the main reason I want to use nano instead.

-SMRT

Last edited by iamsmrt (2009-09-21 19:14:37)

Offline

#2 2009-09-21 19:15:32

milomouse
Member
Registered: 2009-03-24
Posts: 940
Website

Re: Making nano the global editor (including root user)?

maybe add an entry in your shell configuration file, like with me I have:

export EDITOR=/usr/bin/vim

I'm using ZSH shell so I added that to my ~/.zshrc file but I think it's the same for BASH (file: ~/.bashrc). Just replace it with your editor's path, or name.

Last edited by milomouse (2009-09-21 19:16:19)

Offline

#3 2009-09-21 19:19:34

iamsmrt
Member
Registered: 2009-08-12
Posts: 138

Re: Making nano the global editor (including root user)?

I think that's only for your user and doesn't work for root/sudo.

Offline

#4 2009-09-21 19:24:38

milomouse
Member
Registered: 2009-03-24
Posts: 940
Website

Re: Making nano the global editor (including root user)?

You couldn't add export EDITOR=/usr/bin/nano in /etc/profile ? Or something like:

EDITOR="/usr/bin/nano"
export EDITOR

Offline

#5 2009-09-21 19:28:26

iamsmrt
Member
Registered: 2009-08-12
Posts: 138

Re: Making nano the global editor (including root user)?

Yea I've done that but in the nano entry on archwiki (http://wiki.archlinux.org/index.php/Nan … _with_nano):

/etc/profile (global settings for all system users except root)

Last edited by iamsmrt (2009-09-21 19:28:58)

Offline

#6 2009-09-21 19:30:03

ugkbunb
Member
Registered: 2009-02-26
Posts: 227

Re: Making nano the global editor (including root user)?

iamsmrt wrote:

I think that's only for your user and doesn't work for root/sudo.

couldn't u just make a .bashrc/.zshrc in your /root folder with the same export?

Offline

#7 2009-09-21 19:45:44

iamsmrt
Member
Registered: 2009-08-12
Posts: 138

Re: Making nano the global editor (including root user)?

ugkbunb wrote:
iamsmrt wrote:

I think that's only for your user and doesn't work for root/sudo.

couldn't u just make a .bashrc/.zshrc in your /root folder with the same export?

Tried it, it didn't work.

Doing that and editing my /etc/profile to export a VISUAL variable allows me to edit my crontab with nano when I'm logged in as root. However, when I try "sudo crontab -e" logged in as any user (including root), it opens my crontab in vi.

Offline

#8 2009-09-22 00:06:39

neddie_seagoon
Member
Registered: 2009-08-23
Posts: 121

Re: Making nano the global editor (including root user)?

Sudo will first clean out session variables for security, so to make it keep certain ones edit your Defaults line in 'visudo' like:
Defaults env_keep="variable1 variable2"

so in this case:
Defaults env_keep="EDITOR VISUAL"

sudo will then take your current variables and apply them to the new shell.

Offline

#9 2009-09-22 00:38:48

iamsmrt
Member
Registered: 2009-08-12
Posts: 138

Re: Making nano the global editor (including root user)?

neddie_seagoon wrote:

Sudo will first clean out session variables for security, so to make it keep certain ones edit your Defaults line in 'visudo' like:
Defaults env_keep="variable1 variable2"

so in this case:
Defaults env_keep="EDITOR VISUAL"

sudo will then take your current variables and apply them to the new shell.

That works, thanks!

Offline

#10 2009-09-23 05:09:53

iamsmrt
Member
Registered: 2009-08-12
Posts: 138

Re: Making nano the global editor (including root user)?

neddie_seagoon wrote:

Sudo will first clean out session variables for security, so to make it keep certain ones edit your Defaults line in 'visudo' like:
Defaults env_keep="variable1 variable2"

so in this case:
Defaults env_keep="EDITOR VISUAL"

sudo will then take your current variables and apply them to the new shell.

New problem though, whenever I type "sudo gedit foo.bar" I get:

(gedit:22424): Gtk-WARNING **: cannot open display:

Offline

#11 2009-09-23 06:03:45

ugkbunb
Member
Registered: 2009-02-26
Posts: 227

Re: Making nano the global editor (including root user)?

does gksu give the same error?

Offline

#12 2009-09-23 14:54:19

iamsmrt
Member
Registered: 2009-08-12
Posts: 138

Re: Making nano the global editor (including root user)?

Ok that works, what's the difference between gksu and sudo?

Offline

Board footer

Powered by FluxBB