You are not logged in.
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
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
I think that's only for your user and doesn't work for root/sudo.
Offline
You couldn't add export EDITOR=/usr/bin/nano in /etc/profile ? Or something like:
EDITOR="/usr/bin/nano"
export EDITOR
Offline
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
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
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
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
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
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
does gksu give the same error?
Offline
Ok that works, what's the difference between gksu and sudo?
Offline