Control a Shell With pty-shell

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest. →
Hibariya Hi
December 23, 2015

Control a Shell With pty-shell

Introducing pty-shell which is an extension of pty crate

Hibariya Hi

December 23, 2015

Annual Pro sale · Save $30

Have presentations of your own?

Share with private links, password protection, and more control over your work.

Transcript

18 slides
  1. pty

  2. It’s Not Enough My original purpose is to control STDIO

    of a shell process. To accomplish it, I have to do followings. • Do exec a shell command (e.g. bash) • Make parent process enter raw-mode • Connect parent STDIO to child STDIO • Notify winsize changes from parent to child
  3. pty-shell: Control STDIO of a Shell https://github.com/hibariya/pty-shell Spawns a new

    shell and connects to its parent’ s STDIO. Then makes the parent act as proxy. Anyway, you can hook the INPUT/OUTPUT of a shell process. For example: you can play any sound effect and/or you can record or share output of the terminal.
  4. use pty; use pty_shell::{PtyProxy, PtyHandler}; struct MyHandler; impl PtyHandler for

    MyHandler { fn input(&mut self, input: Vec<u8>) { // do something with input } fn output(&mut self, output: Vec<u8>) { // do something with output } }

More Decks by Hibariya Hi

Other Decks in Technology