You are not logged in.

#1 2009-08-24 11:21:19

Gen2ly
Member
From: Sevierville, TN
Registered: 2009-03-06
Posts: 1,529
Website

[Solved] crontab to use .vimrc

I'm guessing this is for checking by crontab (why cron doesn' t use the user's default .vimrc file), but is it safe/possible to use the user's vimrc.  If yes, how can I do it?

Last edited by Gen2ly (2009-08-26 10:45:08)


Setting Up a Scripting Environment | Proud donor to wikipedia - link

Offline

#2 2009-08-24 23:31:28

sand_man
Member
From: Australia
Registered: 2008-06-10
Posts: 2,164

Re: [Solved] crontab to use .vimrc

It does.
Maybe you are doing, sudo crontab -e, that would mean that root doesn't have a .vimrc set.


neutral

Offline

#3 2009-08-25 02:21:38

Profjim
Member
From: NYC
Registered: 2008-03-24
Posts: 658

Re: [Solved] crontab to use .vimrc

Yeah, you could copy or link your user .vimrc to /root. Alternatively, after doing sudo crontab -e, you could (inside vim) type

:so ~myusername/.vimrc

Offline

#4 2009-08-25 05:49:19

Gen2ly
Member
From: Sevierville, TN
Registered: 2009-03-06
Posts: 1,529
Website

Re: [Solved] crontab to use .vimrc

Hmm, I'm using crontab as regular user and have a .vimrc in the home folder.  :so ~myusername/.vimrc does load my ~/.vimrc.  Really be useful to have it loaded on 'crontab -d' as I use it quite a bit.  It appears that cron is somehow discarding or ignoring my default .vimrc.  Kinda at a loss at what's causing this.

Last edited by Gen2ly (2009-08-25 05:51:27)


Setting Up a Scripting Environment | Proud donor to wikipedia - link

Offline

#5 2009-08-25 05:59:16

foutrelis
Developer
From: Athens, Greece
Registered: 2008-07-28
Posts: 705
Website

Re: [Solved] crontab to use .vimrc

I'm not sure, but I think crontab executes `vi' by default (which consults .virc instead). To verify that this is the case, try setting EDITOR=vim when running `crontab' like this:

EDITOR=vim crontab -e

If it works properly with the above command, you'll probably want to make this change permanent by adding the following to your ~/.bashrc:

export EDITOR=vim

EDIT: If the above doesn't work, you can try symlinking .vimrc to .virc.

EDIT2: I had a quick look at dcron's source code for crontab. It checks the VISUAL environment variable and not the EDITOR, defaulting to "/usr/bin/vi" if that's not set. Therefore, `export VISUAL=vim' in ~/.bashrc should do it. smile

Last edited by foutrelis (2009-08-25 06:21:01)

Offline

#6 2009-08-25 06:37:35

Profjim
Member
From: NYC
Registered: 2008-03-24
Posts: 658

Re: [Solved] crontab to use .vimrc

Yes, the crontab in the stock dcron only looks at VISUAL, not EDITOR. So you need to "export VISUAL=vim" or call crontab with:

VISUAL=vim crontab -e

I just released a fork of dcron which looks at EDITOR first, then at VISUAL. But as useful as I think my improvements are, I can't really say this would by itself justify switching.

Last edited by Profjim (2009-08-25 06:39:34)

Offline

#7 2009-08-26 07:12:28

Gen2ly
Member
From: Sevierville, TN
Registered: 2009-03-06
Posts: 1,529
Website

Re: [Solved] crontab to use .vimrc

Oh, yeah, that did it.  Never heard of VISUAL, hmm.  EDITOR, PAGER, VISUAL, lol not even sure what visual would do.  No matter.  Appreciate the help, editing alot easier now.


Setting Up a Scripting Environment | Proud donor to wikipedia - link

Offline

Board footer

Powered by FluxBB