Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xonsh support #44

Merged
merged 3 commits into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@ if command -v nix-your-shell > /dev/null; then
fi
```

### Xonsh

Add to your `~/.config/xonsh/rc.xsh`

```xonsh
if !(which nix-your-shell):
nix-your-shell xonsh | source
```

### Nushell

> [!IMPORTANT]
Expand Down
5 changes: 5 additions & 0 deletions data/env.xsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# If you see this output, you probably forgot to pipe it into `source`:
# nix-your-shell | source

aliases['nix-shell'] = 'nix-your-shell nix-shell -- @($args)'
aliases['nix'] = 'nix-your-shell nix -- @($args)'
6 changes: 5 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,15 @@ fn main() -> eyre::Result<()> {
include_str!("../data/env.nu")
}

ShellKind::Xonsh => {
include_str!("../data/env.xsh")
}

ShellKind::Other(shell) => {
return Err(eyre!(
"I don't know how to generate a shell environment for `{shell}`"
))
.note("Supported shells are: `zsh`, `fish`, `nushell` and `bash`")
.note("Supported shells are: `zsh`, `fish`, `nushell`, `xonsh`, and `bash`")
}
}
.to_owned();
Expand Down
7 changes: 7 additions & 0 deletions src/shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ pub enum ShellKind {
/// <https://www.nushell.sh/>
Nushell,

/// The `xonsh` shell.
/// <https://xon.sh>
Xonsh,

/// A different shell.
Other(String),
}
Expand All @@ -35,6 +39,7 @@ impl Display for ShellKind {
ShellKind::Fish => write!(f, "fish"),
ShellKind::Bash => write!(f, "bash"),
ShellKind::Nushell => write!(f, "nu"),
ShellKind::Xonsh => write!(f, "xonsh"),
ShellKind::Other(shell) => write!(f, "{shell}"),
}
}
Expand Down Expand Up @@ -64,6 +69,8 @@ impl Shell {
ShellKind::Bash
} else if file_name.starts_with("nu") {
ShellKind::Nushell
} else if file_name.starts_with("xonsh") {
ShellKind::Xonsh
} else {
ShellKind::Other(file_name.to_string())
};
Expand Down
Loading