Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/a1ecbr0wn/pshell
Works out if this is running from inside a shell, and if so, which one.
https://github.com/a1ecbr0wn/pshell
bash ksh rust rust-lang shell
Last synced: about 1 month ago
JSON representation
Works out if this is running from inside a shell, and if so, which one.
- Host: GitHub
- URL: https://github.com/a1ecbr0wn/pshell
- Owner: a1ecbr0wn
- License: apache-2.0
- Created: 2022-04-13T09:58:11.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-08-02T08:38:42.000Z (4 months ago)
- Last Synced: 2024-09-18T08:50:53.804Z (about 2 months ago)
- Topics: bash, ksh, rust, rust-lang, shell
- Language: Rust
- Homepage: https://crates.io/crates/pshell
- Size: 46.9 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
# pshell
[![Crates.io](https://img.shields.io/crates/l/pshell)](https://github.com/a1ecbr0wn/pshell/blob/main/LICENSE) [![Crates.io](https://img.shields.io/crates/v/pshell)](https://crates.io/crates/pshell) [![Build Status](https://github.com/a1ecbr0wn/pshell/workflows/CI%20Build/badge.svg)](https://github.com/a1ecbr0wn/pshell/actions/workflows/build.yml) [![docs.rs](https://img.shields.io/docsrs/pshell)](https://docs.rs/pshell) [![dependency status](https://deps.rs/repo/github/a1ecbr0wn/pshell/status.svg)](https://deps.rs/repo/github/a1ecbr0wn/pshell)
`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.
[Usage](#usage) - [Contribute](#contribute)
## Usage
Just a simple function that tells you whether the application is run from inside a shell:
``` rust
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:
``` bash
cargo run --example what_shell
```## Contribute
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.