Crates.io | whattheshell |
lib.rs | whattheshell |
version | 1.1.0 |
source | src |
created_at | 2023-07-23 16:19:29.035063 |
updated_at | 2024-01-15 19:29:13.427989 |
description | Infer the current shell the application is running on |
homepage | https://github.com/zekrotja/whattheshell |
repository | https://github.com/zekrotja/whattheshell |
max_upload_size | |
id | 923835 |
size | 11,286 |
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
.
use whattheshell::Shell;
fn main() {
let shell = Shell::infer().unwrap();
println!("{shell}"); // -> "zsh"
}
This implementation is very much inspired and influenced by the shell infer implementation in Schniz/fnm (see fnm/src/shell).