How to Install and Use Tmux on MacOS: Step-by-Step

Ever been stuck juggling a bunch of tasks in one terminal or hopping between several servers and thinking, “There has to be an easier way”? That’s exactly why I started using Tmux. If you’re looking to improve your workflow with Tmux on MacOS, you’re in the right place. It lets you split your terminal into sections, run multiple shells at once, and switch around without losing your place.
In this guide, I’ll walk you through installing and using Tmux on MacOS, step by step, like I’d show a friend. And if you want to try it on a VPS, Eldernode has some really affordable options to get you started.
What is Tmux?
Tmux is an open-source terminal multiplexer that replaces the GNU screen. It allows you to access multiple terminal sessions simultaneously in a single window. You can run more than one command-line program at the same time and easily switch between multiple programs in one terminal. This terminal session protects your programs from accidentally disconnecting by decoupling them from the main terminal. Also, it is scriptable which lets you create custom Tmux sessions for different purposes. For users specifically interested in MacOS, tmux on MacOS enables a seamless workflow across various sessions.
Installing Tmux on MacOS
In this tutorial from the Mac training series, we will explain the installation method of Tmux on MacOS. You can install Tmux on your Mac operating system with two methods which are: install Tmux using Homebrew and install Tmux without Homebrew. Whichever method you choose, you need to open the terminal. To do this, go to Applications >> Utilities and click on Terminal.
Installing with Homebrew
First, install the Xcode command line tools package using the command below:
xcode-select --install
If you are running macOS High Sierra, Sierra, EL Capitan, or earlier, enter the following command to download the installation script. It’s also a great way to set up Tmux on MacOS quickly.
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
But if you are running Catalina, Mojave, or Big Sur, just enter the command below:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
Once you have installed homebrew successfully, use the command below to install Tmux on your macOS:
brew install tmux
Installing without Homebrew
It is necessary to install the Xcode command line tools package as explained above.
Once you have installed the Xcode, you should download two release tarballs. So proceed to install the latest version of libevent and Tmux. To get the most out of Tmux on MacOS, following these steps ensures proper setup.
Now run the command below to change into unzipped libevent directory:
tar -zxf libevent-*.tar.gz
You can check dependencies as shown below:
./configure --prefix=$HOME/local --enable-shared
To build and install the package, run the following commands:
make
make install
In this step, you should change into unzipped Tmux directory as shown below:
tar -zxf tmux-*.tar.gz
You can check dependencies using the following command:
PKG_CONFIG_PATH=$HOME/local/lib/pkgconfig ./configure --prefix=$HOME/local
And to build and install the package, use the commands below:
make
make install
Note: Remember to substitute your required path for $HOME/local.
Using Tmux on MacOS
To start Tmux just run the following command. For those using MacOS, launching tmux is straightforward and efficient.
tmux
Creating a New Session
You can create a new session using the command below. Tmux on MacOS also lets you manage sessions with ease.
tmux new-session -s <your_session_name>
To view available sessions, enter the following command:
tmux list-sessions
Run the command below to detach from your session when you are done:
tmux detach
And to reattach to your Tmux session when you are ready to continue working using the following command:
tmux attach -t <your_session_name>
Managing Windows and Panes
Here are some of the usual shortcuts to use Tmux. On MacOS, managing windows and panes with tmux boosts productivity.
–> Ctrl-b ?: Show all commands
–> Ctrl+b c: Create a new window
–> Ctrl-b o: Switch
–> Ctrl+b arrow key: Switch pane
–> Ctrl+b “: Split horizontally
–> Ctrl+b %: Split vertically
–> Ctrl+b n: Next
–> Ctrl+b p: Previous
That’s it!
Troubleshooting and Common Errors
⚠️ Tmux command doesn’t show up? Oops, this happens sometimes. Just check with brew list tmux. If it’s not there, reinstall it, easy fix. Tmux on MacOS may also require updating dependencies if troubleshooting.
⚠️ Using Catalina or newer? Forget the old commands, they usually fail. I always use the bash script from Homebrew, no stress.
⚠️ Session won’t attach? Happens to me too. Run tmux list-sessions and make sure the name is exactly right. Typos sneak in all the time.
⚠️ Pane looks cramped? Stretch your terminal window a bit. Tmux needs space to show everything properly, works every time for me.
Conclusion
Tmux is a terminal multiplexer that allows you to run separate processes or commands and preview the output at the same time. Also, you can create multiple windows and panes within the same terminal. In this article, we introduced you to Tmux and taught you how to install and use Tmux on macOS. I hope this tutorial can help you to install Tmux on your mac operating system. You can contact us in the Comments section if you face any problems or have any questions. If you’re looking for expert guidance with Tmux on MacOS, this article should serve as your go-to resource.


