whattheshell

Crates.iowhattheshell
lib.rswhattheshell
version1.1.0
sourcesrc
created_at2023-07-23 16:19:29.035063
updated_at2024-01-15 19:29:13.427989
descriptionInfer the current shell the application is running on
homepagehttps://github.com/zekrotja/whattheshell
repositoryhttps://github.com/zekrotja/whattheshell
max_upload_size
id923835
size11,286
Ringo Hoffmann (zekroTJA)

documentation

https://docs.rs/whattheshell

README

whattheshell

This crate tries to provide a simple solution for a simple problem: "In what shell am I running?"

With Shell::infer(), the currently used shell is tried to be inferred by inspecting the given environment.

On unix-systems, the output of ps -o ppid,comm {pid} is inspected to get the process' parent process which is followed down the tree until a shell process was found. On non-unix system, the same algorithm is used but by the help of the crate sysinfo.

Example

use whattheshell::Shell;

fn main() {
    let shell = Shell::infer().unwrap();
    println!("{shell}"); // -> "zsh"
}

Credits

This implementation is very much inspired and influenced by the shell infer implementation in Schniz/fnm (see fnm/src/shell).

Commit count: 13

cargo fmt