Chris Wiegman

Enabling URL Support in macOS Terminal.app with tmux

| 2 min read
Enabling URL Support in macOS Terminal.app with tmux

I’ve been using tmux on Mac for a very long time. It’s a simple way to get proper panes in Mac’s terminal without replacing the app entirely.

Of course there are replacement apps that handle a lot of this out of the box, but from iTerm to Ghostty and others, they always fall short for me in one way or another. So I stick with Terminal, and honestly, it works really well, minus the pane support. tmux fixes that, but it also overrides so much native Terminal functionality that other basic behavior can break, like clicking a URL.

With a little bit of configuration in ~/.tmux.conf though, you can restore the ability to open links with a right-click. Below is the config to do just that.

setw -g mouse on
set -g word-separators " \t\n"
bind -n MouseDown3Pane select-pane -t= \; copy-mode -M \; send-keys -X select-word \; send-keys -X copy-pipe-and-cancel "sh -c 'read -r url; case \"\$url\" in http://*|https://*) open \"\$url\";; esac'"
bind -T copy-mode-vi    MouseDown3Pane send-keys -X select-word \; send-keys -X copy-pipe-and-cancel "sh -c 'read -r url; case \"\$url\" in http://*|https://*) open \"\$url\";; esac'"
bind -T copy-mode-emacs MouseDown3Pane send-keys -X select-word \; send-keys -X copy-pipe-and-cancel "sh -c 'read -r url; case \"\$url\" in http://*|https://*) open \"\$url\";; esac'"

With this snippet you can simply right-click on a link in Terminal and it will open in your default browser, just like it should.

Looking to do more with your tmux config? Take a look at my full .tmux.conf. It adds a few other quality-of-life tweaks like pane splitting, vi-style copy mode, and more, all without altering Terminal.app’s native look.