5

I scheduled a task using at. The output of the scheduled job was sent to mail. But the output is quite huge; I prefer reading it in a text editor.

Additionally, I don't want to forward the mail, I just want to read locally.

I hope there is a standard way for all *nix. But I use OS X and RedHat.

1
  • which ditribution are you using (ubuntu ? redhat ? )
    – Archemar
    Commented Oct 26, 2015 at 14:26

4 Answers 4

6

You can pipe mail to vim, at least on my test system (RHEL 6.7) it worked.

 mail | vim -

the vim - tells vim to read from standard input

you should see output that say's:

Vim: reading from stdin...

at that point just press the number of the mail item you want to read, IE 1 to read the first message,then press ctrl-d to push it forward.

4

You can open the mail spool file (usually /var/spool/mail/<username>) in vim, but it will contain header information that you probably don't want. Your best bet is to open the message in your mail program, save the message to a file, then open the newly saved file in vim. You'll still have some header information, but much less of it than if you open the mail spool file directly.

1

I have the following lines in my ~/.muttrc so that I can press F6 while viewing any message to pipe it into less.

macro generic <f6> "|less\n" "view with less"
macro index   <f6> "|less\n" "view with less"
macro attach  <f6> "|less\n" "view with less"
macro pager   <f6> "|less\n" "view with less"

IMO, less is the right tool for this job, but if you insist on vim then change all occurrences of less above to vim -

0

I hope I'm answering your question correctly, but you can use The Mutt E-Mail Client and configure it to use Vim.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .