An extension of pty crate.
https://speakerdeck.com/hibariya/control-a-shell-with-pty-shell
Add this to your Cargo.toml
:
```toml [dependencies]
pty = '0.1.6' pty-shell = '0.1.0' ```
For example, add src/main.rs as following:
```rust extern crate pty; extern crate pty_shell;
use pty_shell::{PtyProxy, PtyHandler}; use std::process::{Command, Stdio};
struct Shell;
impl PtyHandler for Shell {
fn input(&mut self, _data: Vec
fn output(&mut self, _data: Vec<u8>) {
aplay("sound-effect-for-output.wav");
}
}
fn aplay
fn main() { let child = pty::fork().unwrap();
child.exec("bash");
child.proxy(Shell);
child.wait();
} ```
Use pty_shell::PtyCallback
.
rust
child.proxy(PtyCallback::new(
|_| aplay("sound1.wav"),
|_| aplay("sound2.wav"),
));
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)Copyright (c) 2015 Hika Hibariya
Distributed under the MIT License.