pub enum Shell {
POSIX(POSIX),
Zsh(Zsh),
Bash(Bash),
Fish(Fish),
}Expand description
Represents different types of Unix shells supported by this library.
This enum provides variants for common Unix shells (POSIX, Zsh, Bash, Fish) along with their specific configuration handling.
§Examples
use what_the_path::Shell;
// Detect current shell
if let Some(shell) = Shell::detect() {
match shell {
Shell::Zsh(_) => println!("Using Zsh"),
Shell::Bash(_) => println!("Using Bash"),
Shell::Fish(_) => println!("Using Fish"),
Shell::POSIX(_) => println!("Using POSIX shell"),
}
}§Variants
POSIX- Default POSIX-compliant shell (like sh)Zsh- Z shellBash- Bourne Again ShellFish- Friendly Interactive Shell
Variants§
Implementations§
Source§impl Shell
impl Shell
Sourcepub fn detect_by_shell_var() -> Result<Shell, ShellError>
pub fn detect_by_shell_var() -> Result<Shell, ShellError>
Detects the current shell by examining the SHELL environment variable.
This function attempts to identify the shell type based on the SHELL environment variable.
It will return None on Windows systems as the SHELL variable is not typically used.
§Returns
Some(Shell)containing the detected shell type if:- Running on a non-Windows system
- The
SHELLenvironment variable exists and contains a recognized shell name
Noneif:- Running on Windows
- The
SHELLenvironment variable does not exist
§Shell Detection
The following shells are recognized (in order):
- Zsh
- Bash
- Fish
- Any other shell is assumed to be POSIX-compliant
pub fn get_rcfiles(&self) -> Result<Vec<PathBuf>, ShellError>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Shell
impl RefUnwindSafe for Shell
impl Send for Shell
impl Sync for Shell
impl Unpin for Shell
impl UnwindSafe for Shell
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more