Shell

Enum Shell 

Source
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 shell
  • Bash - Bourne Again Shell
  • Fish - Friendly Interactive Shell

Variants§

§

POSIX(POSIX)

§

Zsh(Zsh)

§

Bash(Bash)

§

Fish(Fish)

Implementations§

Source§

impl Shell

Source

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 SHELL environment variable exists and contains a recognized shell name
  • None if:
    • Running on Windows
    • The SHELL environment 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
Source

pub fn get_rcfiles(&self) -> Result<Vec<PathBuf>, ShellError>

Trait Implementations§

Source§

impl Debug for Shell

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.