How to crontab -e using nano -w? (no line wrapping)

jasonbuechler

Dabbler
Joined
Mar 28, 2018
Messages
20
So, I hate vi.

[waits for jeers to subside]

If I'm not using notepad++, then I'm using nano. But nano's default line wrapping is silly, and can be changed in several ways...
  • Using meta-L within a nano session (alt-L or esc-L)
  • Setting the option in .nanorc
  • Launching nano with the -w flag
Let's pretend I had an excellent reason to prefer the third option and wanted to crontab -e using nano...
Many minutes of googling showed that lots of people (claim to) have success doing the obvious and throwing the -w flag right into the EDITOR and/or VISUAL environment variable... but I have not been able to repeat that with any variation of shell/env variable/absolute-or-local path to nano. Am I doing something obvious wrong, or is there some freebsd/freenas reason this isn't working?

The inevitable result seems to be: "crontab: /usr/local/bin/nano -w: No such file or directory"

1559074688503.png
 

jasonbuechler

Dabbler
Joined
Mar 28, 2018
Messages
20
Hi dlavigne, thanks for checking out this question.

It seems to happen in any shell I try, unfortunately. (But bash by default, and (t)csh in newly created jails, to really answer you. And 11.2-u3.)

I'm game to try any variation of anything, if you have any suggestions at all.
thank you


1559092263760.png
 

colmconn

Contributor
Joined
Jul 28, 2015
Messages
174
It looks like you cannot do what you want to do using the EDITOR variable. crontab only supports the contents of the EDITOR variable being the filename of the editor to execute. No support for providing command line arguments to said editor is provided. Have a look here to see why.

What you could try is writing a short shell script that invokes your editor of choice passing the command line arguments you want in addition to any others (this latter part is critical), make the script executable and set the EDITOR variable to point to that.

Of the top of my head something like this might work (I leave it you to you to test it out and get it working properly, I've not tested it.)
Code:
#!/bin/sh

/usr/local/bin/nano -w $*
 
Top