Skip to content

Commit b58e2c8

Browse files
Copilotjjerphan
andcommitted
Update CLI help text for shell command and subcommands
Co-authored-by: jjerphan <[email protected]>
1 parent 1018a36 commit b58e2c8

File tree

3 files changed

+100
-3
lines changed

3 files changed

+100
-3
lines changed

docs/source/user_guide/micromamba.rst

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,100 @@ It can be used with a drop-in installation without further steps:
2121
2222
/path/to/micromamba create -p /tmp/env 'pytest>=8.0'
2323
/path/to/micromamba run -p /tmp/env pytest myproject/tests
24+
25+
Shell Command
26+
=============
27+
28+
The ``micromamba shell`` command provides functionality for launching shells and managing shell initialization scripts for environment activation.
29+
30+
Launching a Shell
31+
-----------------
32+
33+
When used without subcommands, ``micromamba shell`` launches a new shell session in the specified environment:
34+
35+
.. code-block:: shell
36+
37+
# Launch a shell in the specified environment
38+
micromamba shell -p /path/to/env
39+
micromamba shell -n myenv
40+
41+
This is particularly useful in CI/CD environments and Docker containers where you need to work within a specific environment.
42+
43+
Shell Initialization Management
44+
-------------------------------
45+
46+
The ``micromamba shell`` command also includes several subcommands for managing shell initialization scripts:
47+
48+
``micromamba shell init``
49+
Add micromamba initialization scripts to your shell's configuration files (e.g., ``.bashrc``, ``.zshrc``).
50+
51+
``micromamba shell deinit``
52+
Remove micromamba initialization scripts from your shell's configuration files.
53+
54+
``micromamba shell reinit``
55+
Restore micromamba initialization scripts in your shell's configuration files.
56+
57+
Environment Activation Scripts
58+
------------------------------
59+
60+
These subcommands generate shell-specific activation code that can be used in scripts or sourced directly:
61+
62+
``micromamba shell activate``
63+
Generate activation code for the specified environment.
64+
65+
``micromamba shell deactivate``
66+
Generate deactivation code to leave the current environment.
67+
68+
``micromamba shell reactivate``
69+
Generate reactivation code to refresh the current environment.
70+
71+
``micromamba shell hook``
72+
Generate shell hook scripts for environment activation.
73+
74+
.. code-block:: shell
75+
76+
# Generate activation code for bash
77+
micromamba shell activate -p /path/to/env -s bash
78+
79+
# Generate deactivation code
80+
micromamba shell deactivate -s bash
81+
82+
# Use in a script
83+
eval "$(micromamba shell activate -p /path/to/env -s bash)"
84+
85+
Supported Shells
86+
----------------
87+
88+
The shell command supports the following shells:
89+
90+
* ``bash`` - Bash shell
91+
* ``zsh`` - Z shell
92+
* ``fish`` - Fish shell
93+
* ``powershell`` - PowerShell
94+
* ``cmd.exe`` - Windows Command Prompt
95+
* ``xonsh`` - Xonsh shell
96+
* ``tcsh`` - Tcsh shell
97+
* ``dash`` - Dash shell
98+
* ``nu`` - Nu shell
99+
* ``posix`` - POSIX-compliant shells
100+
101+
Common Options
102+
--------------
103+
104+
``-s, --shell SHELL``
105+
Specify the shell type. If not provided, micromamba will attempt to detect your shell automatically.
106+
107+
``-p, --prefix PATH``
108+
Specify the environment by its installation path.
109+
110+
``-n, --name NAME``
111+
Specify the environment by its name.
112+
113+
``-r, --root-prefix PATH``
114+
Specify the root prefix (base environment location).
115+
116+
Platform-Specific Features
117+
---------------------------
118+
119+
``micromamba shell enable_long_path_support``
120+
On Windows, this command enables long path support, which allows working with file paths longer than 260 characters.

micromamba/src/shell.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ set_shell_command(CLI::App* shell_subcmd, Configuration& config)
402402
);
403403
set_shell_reinit_command(reinit_subsubcmd, config);
404404

405-
auto* hook_subsubcmd = shell_subcmd->add_subcommand("hook", "Micromamba hook scripts ");
405+
auto* hook_subsubcmd = shell_subcmd->add_subcommand("hook", "Output shell hook scripts for environment activation");
406406
set_shell_hook_command(hook_subsubcmd, config);
407407

408408
auto* acti_subsubcmd = shell_subcmd->add_subcommand(
@@ -425,7 +425,7 @@ set_shell_command(CLI::App* shell_subcmd, Configuration& config)
425425

426426
auto* long_path_subsubcmd = shell_subcmd->add_subcommand(
427427
"enable_long_path_support",
428-
"Output deactivation code for the given shell"
428+
"Enable long path support on Windows"
429429
);
430430
set_shell_long_path_command(long_path_subsubcmd, config);
431431

micromamba/src/umamba.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ set_umamba_command(CLI::App* com, mamba::Configuration& config)
3939

4040
com->add_flag_function("--version", print_version);
4141

42-
CLI::App* shell_subcom = com->add_subcommand("shell", "Generate shell init scripts");
42+
CLI::App* shell_subcom = com->add_subcommand("shell", "Launch a shell or manage shell initialization scripts");
4343
set_shell_command(shell_subcom, config);
4444

4545
CLI::App* create_subcom = com->add_subcommand("create", "Create new environment");

0 commit comments

Comments
 (0)