Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

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 dont want to forward the mail I just want to read locally.

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

share|improve this question
    
which ditribution are you using (ubuntu ? redhat ? ) – Archemar yesterday

4 Answers 4

up vote 5 down vote accepted

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.

share|improve this answer

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.

share|improve this answer

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 -

share|improve this answer

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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