term-detect

Crates.ioterm-detect
lib.rsterm-detect
version0.1.8
sourcesrc
created_at2023-07-28 16:21:53.583792
updated_at2024-11-28 16:53:02.548083
descriptionTerminal emulator detector
homepage
repositoryhttps://gitlab.com/fnrir/term-detect
max_upload_size
id928626
size19,257
(fnr1r)

documentation

README

term-detect

Terminal emulator detector

Implementation details

It works using 3 methods.

  1. TERMINAL environment variable
    The terminal is detected by reading the TERMINAL environment variable.
  2. DE (desktop environment) specific checks
    The terminal is detected by checking DE-specific config files.
  3. $PATH search
    The terminal from a list is picked if it's found in $PATH.

Examples

Run fish in private mode in a terminal window. Don't close the window when the command ends.

use std::process::Command;
use term_detect::{DetectionError, InTerminalAuto};

fn main() -> Result<(), DetectionError> {
    let child = Command::new("fish")
        .arg("--private")
        // Konsole-specific flag
        .in_terminal_args(["--noclose"])?
        .spawn()?
        .wait()?;
    Ok(())
}
Commit count: 19

cargo fmt