How to Integrate mise with Your Shell: Complete Setup Guide for Bash, Zsh, and Fish
To integrate mise with your shell, evaluate the activation script in your shell's startup file using eval "$(mise activate)" for Bash/Zsh or eval (mise activate fish) for Fish, which configures environment variables and PATH via the Shell trait implemented in src/shell/mod.rs.
The jdx/mise repository provides a universal runtime manager that integrates with shells through a trait-based abstraction layer. Understanding how to integrate mise with shell environments requires examining the Shell trait and its concrete implementations that generate shell-specific activation scripts.
Shell Integration Architecture
The core of mise shell integration resides in the Shell abstraction defined in src/shell/mod.rs. Each supported shell implements this trait to provide the exact syntax required for environment manipulation.
The Shell trait exposes these key methods:
activate(&self, opts: ActivateOptions) -> String– Returns a shell-specific script that exports variables, configures shims, and optionally enables command-not-found handling.deactivate(&self) -> String– Returns cleanup logic for removing mise environment variables.set_env,prepend_env,unset_env– Emit the proper syntax for environment variable operations.move_prepend_envandsupports_move_path– Enable PATH deduplication in shells like Fish.
When you execute mise activate, the CLI resolves the appropriate implementation via ShellType::as_shell() (lines 27-38 in src/shell/mod.rs), either auto-detecting your current shell or using the explicitly provided argument.
Supported Shells and Integration Commands
Each shell has a dedicated implementation file under src/shell/ that generates compatible activation syntax.
Bash Integration
The Bash implementation in src/shell/bash.rs generates standard export syntax. Add this to ~/.bashrc:
eval "$(mise activate)"
Or specify the shell explicitly:
eval "$(mise activate bash)"
Zsh Integration
The Zsh implementation in src/shell/zsh.rs follows the same pattern as Bash. Add to ~/.zshrc:
eval "$(mise activate zsh)"
Fish Integration
The Fish implementation in src/shell/fish.rs uses Fish-specific set -gx syntax and defines a mise function wrapper. Fish requires parentheses for command substitution:
# ~/.config/fish/config.fish
eval (mise activate fish)
Fish additionally leverages move_prepend_env for efficient PATH deduplication that other shells handle differently.
PowerShell Integration
For PowerShell, located in src/shell/pwsh.rs, pipe the output to Invoke-Expression:
# $PROFILE
mise activate pwsh | Invoke-Expression
How the Activation Script Works
When evaluated, the activation script executes three phases defined in src/shell/mod.rs:
- Deactivation – Calls
build_deactivation_script(lines 33-42) to clear any existing mise environment. - Prelude – Applies
format_activate_preludeto handle custom environment tweaks passed via--preludeflags. - Environment Setup – Exports
MISE_*variables, prepends shim directories to PATH, and optionally installs a command-not-found handler ifSettings::not_found_auto_installis enabled.
Advanced Configuration Options
Custom Environment Preludes
Prepend directories or set variables before activation using prelude arguments:
eval "$(mise activate bash --prelude 'prepend PATH /opt/mytools')"
The CLI parses these into ActivatePrelude::Prepend entries that format_activate_prelude renders with the correct shell syntax.
Deactivation
To temporarily disable mise in a session:
mise deactivate
This executes the cleanup script returned by Shell::deactivate(), removing all mise-related environment modifications.
Summary
- Integration method: Evaluate
mise activateoutput in your shell's rc file usingevalfor Bash/Zsh,evalwith parentheses for Fish, orInvoke-Expressionfor PowerShell. - Core abstraction: The
Shelltrait insrc/shell/mod.rsprovides shell-agnostic activation viaShellType::as_shell(). - Concrete implementations: Each shell has dedicated logic in
src/shell/bash.rs,src/shell/fish.rs,src/shell/zsh.rs, andsrc/shell/pwsh.rs. - Activation sequence: Clears previous state, applies preludes, then sets environment variables and PATH.
- Auto-installation: Optional command-not-found handling triggers when
Settings::not_found_auto_installis enabled.
Frequently Asked Questions
How does mise auto-detect which shell I'm using?
When you run mise activate without arguments, the CLI calls ShellType::as_shell() in src/shell/mod.rs (lines 27-38) to detect the parent process and instantiate the correct Shell trait implementation, ensuring the generated script matches your shell's syntax requirements.
Can I integrate mise with multiple shells simultaneously?
Yes, but each shell requires its own configuration line in the respective rc file. The Shell trait guarantees each shell receives syntactically correct activation scripts—Fish receives set -gx commands while Bash receives export statements—so configurations are not interchangeable between shell files.
What is the command-not-found handler and how do I enable it?
The command-not-found handler intercepts unrecognized commands and attempts automatic installation via mise. It activates when Settings::not_found_auto_install is enabled in your mise configuration, triggering shell-specific handler scripts such as bash/command_not_found.sh referenced in src/shell/bash.rs.
Why does Fish use different syntax for mise activation?
Fish uses parentheses () for command substitution instead of $(), and requires the mise function wrapper defined in src/shell/fish.rs to forward commands to the binary. The Fish implementation also utilizes move_prepend_env for efficient PATH deduplication, which other shells handle through different mechanisms.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →