@wallhackio When I type :ha to print out a file, the script first counts the pages and prompts me to confirm that I want to print out that many pages, and then sends it to the printer if I said yes

So that if I decide I don't want to print 25 pages of code actually, I still have a chance to say no

@wallhackio Here's the source code, I put this in my .vimrc:

function PrintFile()
let pg = systemlist("awk '/^%%Pages: [0-9]+/ { print $2 }' " .. v:fname_in)[0]
let r = input("Print " .. pg .. " pages? ")
if r[0] == "y" || r[0] == "Y"
call system('lpr' .. (&printdevice == '' ? '' : ' -P' .. &printdevice) .. ' ' .. v:fname_in)
call delete(v:fname_in)
return v:shell_error
else
call delete(v:fname_in)
return 1
endif
endfunc
set printexpr=PrintFile()
Sign in to participate in the conversation
📟🐱 GlitchCat

A small, community‐oriented Mastodon‐compatible Fediverse (GlitchSoc) instance managed as a joint venture between the cat and KIBI families.