4

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.

  • which ditribution are you using (ubuntu ? redhat ? ) – Archemar Oct 26 '15 at 14:26
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.

0

<joost> Do you mean to say that I can read mail with vi too? ;-)

<Joey> Didn't you know that?

<Joey> :r /var/spool/mail/jk

— Seen on #debian-mentors

— From Linux Fortune's (fortune linux)

You can read mail from Vim, with this command:

:r /var/spool/mail/{USER}
" replace {USER} with your username on Linux

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.