4

I found out about printing using the :hardcopy command, and on my Mac it opens up the output in a PDF named "0.pdf", then the next printing from that file opens "1.pdf", etc.

I can save these files, of course, but I'm wondering: Where are these files stored on disk? Is there a setting which controls it somewhere?

I haven't been able to find the output files anywhere, including checking /tmp. Appreciate any tips in the right direction.


:set printexpr? yields system('open -a Preview '.v:fname_in) + v:shell_error

The PDF viewer can't be made to show the file as being anywhere. All usual methods for finding where the currently open file is aren't working at all.

3
  • Where does your PDF viewer show them as being located?
    – muru
    Mar 15, 2016 at 6:26
  • 1
    The printexpr setting should be used for this; so using :set printexpr? might yield some useful information? Mar 15, 2016 at 6:47
  • @Carpetsmoker, I updated the question with the answers to your and muru's questions.
    – Wildcard
    Mar 15, 2016 at 8:34

2 Answers 2

4

I found it using lsof:

/private/var/folders/cr/jsb8dl_50lbdy05hj7v2l9wr0000gn/T/com.apple.Preview/PreviewTemp-79NyiU/0.pdf

And then I found the other files alongside it using find:

find /private/var/folders/cr/jsb8dl_50lbdy05hj7v2l9wr0000gn/T/com.apple.Preview -type f

I still don't know why it was put here, but at least I found it.

2
  • 1
    You could have found it by dragging the icon in the title bar to a terminal window.
    – romainl
    Mar 15, 2016 at 8:44
  • @romainl, indeed! Usually right click on the icon will show the parent directories, but not in this case. Dragging did the trick and is much faster than lsof; thanks!
    – Wildcard
    Mar 15, 2016 at 8:50
4

From :help pexpr-option:

Expression that is evaluated to print the PostScript produced with :hardcopy. The file name to be printed is in v:fname_in.

It's a bit of a hack, but you can simply echo the v:fname_in variable to a file:

:let &printexpr = "system('echo '.v:fname_in.'>> /home/martin/hardcopy')"

And then examine the created hardcopy file, I found that on my Linux system it's /tmp/vVLcfMS/6, which indeed looks like a postscript file with the contents of my buffer ;-)

For OS X you probably want to use a path like /Users/Wildcard/hardcopy...

Pretty sure there's an easier way than this in OS X somehow, unless Saint Jobs the Magnificent decided that this was somehow not required for his petty mortal users (would not surprise me)... In any case, it's a useful lesson in basic "printf debugging" ;-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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