-
Notifications
You must be signed in to change notification settings - Fork 347
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #1655
- Loading branch information
Showing
15 changed files
with
263 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# `mise en` | ||
|
||
- **Usage**: `mise en [-s --shell <SHELL>] [DIR]` | ||
- **Source code**: [`src/cli/en.rs`](https://github.com/jdx/mise/blob/main/src/cli/en.rs) | ||
|
||
[experimental] starts a new shell with the mise environment built from the current configuration | ||
|
||
This is an alternative to `mise activate` that allows you to explicitly start a mise session. | ||
It will have the tools and environment variables in the configs loaded. | ||
Note that changing directories will not update the mise environment. | ||
|
||
It's a lightweight alternative to `mise activate` if you don't want to put that into your shell rc but | ||
still don't want to deal with shims. It probably only makes sense for interactive use-cases. | ||
|
||
It's sort of akin to manually running `source .venv/bin/activate` for Python virtualenvs if you're | ||
familiar with that workflow. | ||
|
||
## Arguments | ||
|
||
### `[DIR]` | ||
|
||
Directory to start the shell in | ||
|
||
**Default:** `.` | ||
|
||
## Flags | ||
|
||
### `-s --shell <SHELL>` | ||
|
||
Shell to start | ||
|
||
Defaults to $SHELL | ||
|
||
Examples: | ||
|
||
$ mise en . | ||
$ node -v | ||
v20.0.0 | ||
|
||
Skip loading bashrc: | ||
$ mise en -s "bash --norc" | ||
|
||
Skip loading zshrc: | ||
$ mise en -s "zsh -f" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
use crate::cli::exec::Exec; | ||
use crate::config::Settings; | ||
use std::path::PathBuf; | ||
|
||
use crate::env; | ||
|
||
/// [experimental] starts a new shell with the mise environment built from the current configuration | ||
/// | ||
/// This is an alternative to `mise activate` that allows you to explicitly start a mise session. | ||
/// It will have the tools and environment variables in the configs loaded. | ||
/// Note that changing directories will not update the mise environment. | ||
#[derive(Debug, clap::Args)] | ||
#[clap(verbatim_doc_comment, after_long_help = AFTER_LONG_HELP)] | ||
pub struct En { | ||
/// Directory to start the shell in | ||
#[clap(default_value = ".", verbatim_doc_comment, value_hint = clap::ValueHint::DirPath)] | ||
pub dir: PathBuf, | ||
|
||
/// Shell to start | ||
/// | ||
/// Defaults to $SHELL | ||
#[clap(verbatim_doc_comment, long, short = 's', env = "MISE_SHELL")] | ||
pub shell: Option<String>, | ||
} | ||
|
||
impl En { | ||
pub fn run(self) -> eyre::Result<()> { | ||
let settings = Settings::get(); | ||
settings.ensure_experimental("en")?; | ||
|
||
env::set_current_dir(&self.dir)?; | ||
let shell = self.shell.unwrap_or((*env::SHELL).clone()); | ||
let command = shell_words::split(&shell).map_err(|e| eyre::eyre!(e))?; | ||
|
||
Exec { | ||
tool: vec![], | ||
raw: false, | ||
jobs: None, | ||
c: None, | ||
command: Some(command), | ||
} | ||
.run() | ||
} | ||
} | ||
|
||
static AFTER_LONG_HELP: &str = color_print::cstr!( | ||
r#"<bold><underline>Examples:</underline></bold> | ||
$ <bold>mise en .</bold> | ||
$ <bold>node -v</bold> | ||
v20.0.0 | ||
Skip loading bashrc: | ||
$ <bold>mise en -s "bash --norc"</bold> | ||
Skip loading zshrc: | ||
$ <bold>mise en -s "zsh -f"</bold> | ||
"# | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.