[colug-432] tmux escape codes

Greg Sidelinger gate at ilive4code.net
Fri May 17 12:12:51 EDT 2013


Here is a very simple python script which will send a file to stdout with
the proper esc sequence for the terminal to see it as a print job.  I don't
recommend testing it with anything other than small text files.  I did
notice that screen seems to "work".  I do have a much "better" version of
the bellow script which has a lot of error checking and actually reads the
file in small chunks while writing it to stdout.  But this one gets the
idea across very quickly.


#!/usr/bin/python
import tty, sys, termios

# read file and waste lots of memory while doing it
try:
	tmpfile = sys.argv[1]
except:
	print "\nPlease pass in a file name\n"
	sys.exit()
fileobj = open(tmpfile, mode='rb')
data = fileobj.read()
fileobj.close()

# Get term props and make stdout raw
att = termios.tcgetattr(sys.stdout)
tty.setraw(sys.stdout)

sys.stdout.write("\033[5i" + data + "\033[4i")

# reset terminal
termios.tcsetattr(sys.stdout, termios.TCSADRAIN , att)



On Fri, May 17, 2013 at 10:37 AM, Chris Clonch <chris at theclonchs.com> wrote:

> > A quick test with a single 80x24 window horizontally split into two
> > 40x24 panes and running "tput cup 0 60" results in the first letter of
> > my prompt at the end of row 1 and cursor placed after the prompt on row
> 2.
>
> Screenshot of my term..
>
> http://en.zimagez.com/zimage/screenshot-05172013-103530am.php
>
> _______________________________________________
> colug-432 mailing list
> colug-432 at colug.net
> http://lists.colug.net/mailman/listinfo/colug-432
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.colug.net/pipermail/colug-432/attachments/20130517/ff0b0514/attachment.html 


More information about the colug-432 mailing list