#shell #filesystem #utility


Works out if this is running from inside a shell, and if so, which one

4 stable releases

Uses new Rust 2021

1.0.4 Aug 1, 2022
1.0.1 Apr 13, 2022

#110 in Operating systems

Download history 4/week @ 2022-04-20 18/week @ 2022-04-27 20/week @ 2022-05-04 44/week @ 2022-05-11 15/week @ 2022-05-18 13/week @ 2022-05-25 27/week @ 2022-06-01 12/week @ 2022-06-08 6/week @ 2022-06-15 11/week @ 2022-06-22 4/week @ 2022-06-29 6/week @ 2022-07-06 6/week @ 2022-07-13 14/week @ 2022-07-20 61/week @ 2022-07-27 38/week @ 2022-08-03

119 downloads per month
Used in bookmark-cd




Crates.io Crates.io Build Status docs.rs dependency status

pshell answers the question "Is my application running in a shell, and if so, which one".

Example: you are installing something and want to make changes to the shell and you want to know what changes are required to which shell script.


Just a simple function that tells you whether the application is run from inside a shell:

use pshell;

fn main() {
    // `find` returns the name of the shell in a string and the pid as a u32
    let (sh, pid) = pshell::find().unwrap_or(("unknown".to_string(), 0));
    println!("This application has been run from pid `{}`, which is a {} shell", pid, sh);

To try this out, and check it works OK on your OS/shell combination run the following from your shell:

cargo run --example what_shell


I have created a list of shells where this could be run from, it is not exhaustive, if your shell is not supported, feel free to raise an issue or a PR.


~15K SLoC