Tmux in Linux and Mac With Wezterm
After struggling to get tmux
to run seamlessly between Mac (on ARM i.e. M1/M2)
and linux due to the fact that brew
installs packages to /opt/homebrew/bin/
and it isn't on the path before the shell loads, I have finally worked out how to
get tmux to launch/attach to existing sessions when launching a new terminal both
in linux and on MacOS.
I use wezterm as my terminal emulator as I can maintain the same settings for the terminal between my linux and mac (sorry iterm peeps).
I won't get into why I love it, but it is fast, has a very nice dev, and supports ligatures in fonts which - while divisive to some - I like so I use this.
Long story short. Here is the wezterm.lua
config that you can store in your
~/.config/wezterm/wezterm.lua
.
local wezterm = require
local tmux =
if wezterm. == "aarch64-apple-darwin"
return
They key lines is the local tmux
path. Wezterm won't launch
if you don't pass it explicitly as the path is not known by default
to wezterm.
The second thing you need to change is to get your tmux config to append that brew path to the $PATH as well.
.tmux.conf
:
-g mouse on
-s set-clipboard on
-g PATH "/opt/homebrew/bin:/bin:$PATH"
-g mode-keys vi
/ split-window -h -c "#{pane_current_path}"
- split-window -v -c "#{pane_current_path}"
'"'
%
-r ^ last-window
-r k select-pane -U
-r j select-pane -D
-r h select-pane -L
-r l select-pane -R
C new-window -c "#{pane_current_path}"
-r f run-shell "tmux neww ~/.local/bin/tmux-sessionizer"
-ga terminal-overrides ",xterm-256color:Tc"
-sa terminal-overrides ',screen-256color:RGB'
-g @plugin 'tmux-plugins/tpm'
-g @plugin 'catppuccin/tmux'
-g @plugin 'tmux-plugins/tmux-sensible'
-sg escape-time 5
-g focus-events on
-g default-shell /bin/zsh
-file ~/.tmux.conf
r source
'~/.tmux/plugins/tpm/tpm'
All of this can be seen in my dotfiles.