It should have happened to you that you want to do several tasks at the same time in one terminal or work with several different servers. You can do this with the Tmux. This program allows you to divide a terminal into several sections and have a shell in each section and do whatever you like. This article will teach you How to Install And Use Tmux on MacOS. Eldernode‘s website offers economical VPS packages, which can be the best choice if you intend to buy.
Table of Contents
2 way to Setup Tmux on MacOS System
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.
Installing Tmux on MacOS with 2 Way
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.
1) How to Install Tmux Using 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:
/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
2) How to Install Tmux 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.
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:
tmux
You can create a new session using the command below:
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>
Here are some of the usual shortcuts to use Tmux:
–> 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!
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.