Set tmux as the default shell in WSL
To set tmux as your default shell on WSL Linux, you can modify your shell’s configuration file. Here’s a step-by-step guide:
-
Locate Your Shell Configuration File:
bash nano ~/.bashrc -
Add Conditional Statements: At the end of the file, add the following code:
if command -v tmux &> /dev/null && [ -z "$TMUX" ]; then tmux attach-session -t default || tmux new-session -s default fiThis ensures that:
Tmux is installed (
command -v tmux). You’re not already in a tmux session ([ -z "$TMUX" ]). It tries to attach to an existing session nameddefaultor creates a new one. - Save and Exit: Press
Ctrl+Oto save andCtrl+Xto exit the editor. -
Apply Changes: Run the following command to apply the changes:
source ~/.bashrcOr restart your terminal.