fake-tty 0.3.1

Run command with bash pretending to be a tty
Documentation
  • Coverage
  • 100%
    5 out of 5 items documented2 out of 5 items with examples
  • Size
  • Source code size: 7.96 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 797.51 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 8s Average build duration of successful builds.
  • all releases: 8s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • Aloso/to-html
    90 11 12
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Aloso

fake-tty

Documentation

Rust library to run a command in bash, pretending to be a tty. This means that the command will assume that terminal colors and other terminal features are available. This is done by executing the script command.

Note that some programs might still behave differently than they would in a real terminal. For example, on my system, ls always displays colors in the terminal, but requires --color=auto when executed in fake-tty.

Example

let output = fake_tty::bash_command("ls --color=auto").output().unwrap();
assert!(output.status.success());

let _stdout: String = String::from_utf8(output.stdout).unwrap();

Platform support

As of now, fake-tty supports Linux, macOS and FreeBSD.

Adding support other platforms should be easy, if they support bash and the script command. On Windows, it might be possible to use cmd or PowerShell instead; please send a pull request if you need Windows support.