1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-27 02:25:28 +03:00

allow piping an image into wezterm imgcat

Playing with @katef's plot utility:

https://gist.github.com/katef/fb4cb6d47decd8052bd0e8d88c03a102

```
~/plot.awk < /tmp/data | rsvg-convert | wezterm imgcat
```
This commit is contained in:
Wez Furlong 2020-10-16 13:17:47 -07:00
parent 0ec79a40f6
commit 8e6c2cfa2a

View File

@ -262,16 +262,22 @@ struct ImgCatCommand {
/// ratio
#[structopt(long = "preserve-aspect-ratio")]
no_preserve_aspect_ratio: bool,
/// The name of the image file to be displayed
/// The name of the image file to be displayed.
/// If omitted, will attempt to read it from stdin.
#[structopt(parse(from_os_str))]
file_name: OsString,
file_name: Option<OsString>,
}
impl ImgCatCommand {
fn run(&self) -> anyhow::Result<()> {
let mut f = std::fs::File::open(&self.file_name)?;
let mut data = Vec::new();
f.read_to_end(&mut data)?;
if let Some(file_name) = self.file_name.as_ref() {
let mut f = std::fs::File::open(file_name)?;
f.read_to_end(&mut data)?;
} else {
let mut stdin = std::io::stdin();
stdin.read_to_end(&mut data)?;
}
let osc = OperatingSystemCommand::ITermProprietary(ITermProprietary::File(Box::new(
ITermFileData {