
Fixing Midnight Commander (MC) Performance Issues with Zsh, Oh My Zsh, and Powerlevel10k


Midnight Commander (MC) is a powerful and versatile file manager for the terminal, beloved by many for its dual-pane interface and rich feature set. However, when using it in combination with Zsh, Oh My Zsh, and the Powerlevel10k (p10k) theme, users may encounter performance issues and errors that can hinder their workflow. Specifically, MC may take an unusually long time to load (5-7 seconds instead of being instantaneous) and might throw errors like "the shell is already running a command" when attempting to execute commands or navigate directories. In this article, we’ll explore the root cause of these issues and provide a step-by-step solution to resolve them.
Understanding the Problem

ohmyzsh
The combination of Zsh, Oh My Zsh, and Powerlevel10k is a popular setup for terminal users due to its enhanced functionality, aesthetics, and customization options. However, this setup can sometimes interfere with applications like Midnight Commander, which rely on shell interactions to function properly. The two main symptoms of this issue are:
- Slow Startup Time: MC takes significantly longer to launch compared to its usual instant startup.
- Shell Command Errors: When attempting to run commands or change directories within MC, users may encounter the error message: "the shell is already running a command."
These issues arise because MC is designed to work seamlessly with simpler shell environments. When running under Zsh with Oh My Zsh and Powerlevel10k, the additional overhead and configurations can cause conflicts or delays.
The Root Cause
The primary cause of these issues lies in how MC interacts with the shell. By default, MC uses the same shell as the one in which it was launched (in this case, Zsh). However, Zsh with Oh My Zsh and Powerlevel10k introduces a significant amount of initialization code, plugins, and theme rendering, which can slow down MC’s startup and cause conflicts during shell command execution.
Additionally, the error "the shell is already running a command" suggests that MC is attempting to run a new shell command while the current shell session is still processing its initialization scripts or other tasks. This can happen because Zsh with Oh My Zsh and Powerlevel10k is not optimized for the kind of lightweight, fast shell interactions that MC requires.
The Solution: Running MC with a Simpler Shell
To resolve these issues, we can configure MC to use a simpler shell, such as Bash, instead of Zsh. This ensures that MC operates in a lightweight environment, free from the overhead of Oh My Zsh and Powerlevel10k. Here’s how to do it:
Step 1: Identify the Paths to Bash and MC
First, we need to determine the paths to both Bash and MC on your system. Open your terminal and run the following commands:
which bash
which mc
The output will look something like this:
/bin/bash
/opt/homebrew/bin/mc
Make a note of these paths, as we’ll use them in the next step.
Step 2: Create an Alias in .zshrc
Next, we’ll create an alias in your .zshrc
file to ensure that MC always launches with Bash as its shell. Open your .zshrc
file in a text editor:
nano ~/.zshrc
Add the following line to the file, replacing the paths with the ones you obtained in Step 1:
alias mc="SHELL=/bin/bash /opt/homebrew/bin/mc"
This alias tells your terminal to use Bash as the shell whenever MC is launched, bypassing Zsh and its associated configurations.
Step 3: Apply the Changes
After saving the changes to your .zshrc
file, you’ll need to apply them. You can do this by either sourcing the file:
source ~/.zshrc
or by restarting your terminal.
Testing the Solution
Once the alias is in place, launch MC by simply typing mc
in your terminal. You should notice two immediate improvements:
- Faster Startup: MC should now launch almost instantly, without the 5-7 second delay.
- No More Errors: Commands and directory changes within MC should work smoothly, without the "the shell is already running a command" error.
Why This Works
By forcing MC to use Bash instead of Zsh, we eliminate the overhead and potential conflicts introduced by Oh My Zsh and Powerlevel10k. Bash is a simpler shell with fewer initialization scripts, making it more suitable for applications like MC that require fast and reliable shell interactions.
Additional Tips
- Customizing the Alias: If you have multiple versions of Bash or MC installed, you can customize the alias to point to the specific paths you prefer.
- Using Other Shells: If you prefer a different lightweight shell (e.g., Dash), you can substitute Bash with that shell in the alias.
- Reverting the Changes: If you ever want to revert to using Zsh with MC, simply remove the alias from your
.zshrc
file and restart your terminal.