Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zekrotja/whattheshell
The answer to the question "In what shell am I running?" - Infer terminal shell
https://github.com/zekrotja/whattheshell
cli rust shell terminal
Last synced: about 1 month ago
JSON representation
The answer to the question "In what shell am I running?" - Infer terminal shell
- Host: GitHub
- URL: https://github.com/zekrotja/whattheshell
- Owner: zekroTJA
- License: mit
- Created: 2023-07-23T16:15:07.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-03-28T16:15:12.000Z (10 months ago)
- Last Synced: 2024-12-06T18:53:52.201Z (about 1 month ago)
- Topics: cli, rust, shell, terminal
- Language: Rust
- Homepage: https://docs.rs/whattheshell/latest/whattheshell/index.html
- Size: 12.7 KB
- Stars: 9
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
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`](https://crates.io/crates/sysinfo).
## Example
```rust
use whattheshell::Shell;fn main() {
let shell = Shell::infer().unwrap();
println!("{shell}"); // -> "zsh"
}
```## Supported shells
Here you can find a list of currently supported shells.
- Shell (`sh`)
- Bash (`bash`)
- Z shell (`zsh`)
- Fish (`fish`)
- Nushell (`nu`)
- PowerShell (`powershell`, `pwsh`)
- Cmd (`cmd`)Are you missing a shell? Feel free to [create an issue](https://github.com/zekroTJA/whattheshell/issues/new) or create a pull request with an implementation.
## Credits
This implementation is very much inspired and influenced by the shell infer implementation in [Schniz/fnm](https://github.com/Schniz/fnm) (see [fnm/src/shell](https://github.com/Schniz/fnm/tree/master/src/shell)).