Skip to content

plcp/ptyrc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ptyrc – the pty remote controller

This started as a wrapper around pty which grew until it walked on its own.

The initial goal was to wrap a CLI application like vim to add confetti to its output.

confetti

Quick setup

This is not yet published on PyPI:

python3 -m venv venv
source venv/bin/activate
pip install git+https://github.com/plcp/ptyrc.git@main

Wrap any application with a ptyrc driver as follows:

ptyrc-driver vim ~/.vimrc

You can then connect to the driver as follows:

ptyrc-pilot # (by default, run an interactive session)

This is an example of an interactive session with the pilot:

Connected to "/usr/bin/vim /home/plcp/.vimrc"
>>> pilot.argv
['/usr/bin/vim', '/home/plcp/.vimrc']
>>> pilot.size
[103, 13]
>>> pilot.cursor
[17, 5]
>>> pilot.input(pilot.key.ARROW_UP * 4 + pilot.key.ARROW_LEFT * 16)
>>> pilot.cursor
[1, 1]
>>> pilot.input(pilot.key.ESC + 'o' + 'hello world!')
>>> pilot.text_at(pilot.cursor_row)
'hello world!'
>>> pilot.input(pilot.key.ESC + 'dd')
>>> pilot.input(':q!' + pilot.key.ENTER)
>>> pilot.connected
False
>>> pilot.quit()

You can also use ptyrc to display the remote application:

>>> pilot.show()  # show remote terminal as text (^C to exit)
>>> pilot.interact()  # interact with remote terminal (^X to exit)

interact

Long term goal is to add everything to manipulate the wrapped CLI, just as selenium manipulates browsers.

Usage

This whole project has no tests and no documentation.

YMMV :)

About

the pty remote controller

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published