How To Get Started with tmux
tmux
Quite simply, tmux allows you to run multiple terminal command lines at the same time side by side much like putting multiple windows next to each other so you see both simultaneously. It stands for “terminal multiplexer”, a fancy term for something so logical. Here are the basics to get you started with tmux quickly.
First of all, just run tmux. You will very likely have it in your system no matter which Linux or UNIX distribution you’re using. Otherwise you can get it from the tmux website. For MacOS, I suggest using brew package manager.
And you’re in. Not much has changed, but you should see the green bar at the bottom, which is the tmux status bar showing you which window you’re in, date and time, and the hostname of your system. The goodness is in the keyboard commands that you can now use to split the current window into multiple panes, or to create new windows with their own panes. You can then switch between panes and windows with ease.
The way keyboard commands work is by first pressing a shortcut CTRL-B, and then entering a character corresponding to a command. For example, to split the current window or pane into two vertical panes press CTRL-B %. Just press CTRL-B together, then enter the % normally, and it will split.
Here are a few of the basic commands that will have you up and going with tmux with ease:
- CTRL-B % – split into two vertical panes (as mentioned)
- CTRL-B “ – split into two horizontal panes
- CTRL-B z – make the current pane full screen (press again to exit full screen)
- CTRL-B arrow-key – switch between panes with arrow keys. For example
- CTRL-B up-arrow – will switch to the pane above the currently active one.
- CTRL-B c – create a new window. You will notice it indicated in the green status bar under a number.
- CTRL-B number – switch to a window. To switch to a window 0, for example, press CTRL-B 0.
With these shortcuts you can create as many panes and windows as you need, and switch between them.
One more thing though. These sets of windows and panes are known as tmux sessions, and you can actually have multiple of them, and they are saved on the system so that they can be attached to different terminals you can in from.
You can detach from the current session with CTRL-B d, and you’ll end up back on the normal bare command line. Then you can run this to list all of the sessions with its numbers:
You’ll see something like:
Then you can attach to session 0, for example, with this command:
And if you no longer want a particular session you can kill it:
You can see the full breakdown of sessions, their windows, and their panes by issuing this command:
Other useful commands with more information:
- tmux list-keys
- tmux list-commands
- man tmux
See Also
- macOS
- tmux
- tmux reference
- How To Get Started with tmux
- Official tmux page
- Official Brew package manager page
- Useful software for Unix/Linux
- Install latest tmux in macOS
- tmux – terminal multiplexer
- tmux settings
- tmux previews for windows and sessions
- preview windows in tmux
- Change default tmux key
- tmux
- Really cool: tmux sessions survive graphics desktop logout
- How To: Change tmux Meta Key
- Getting Started with tmux
- Basic tmux configuration
- tmux sessions and graphics login to GNOME/KDE
- Getting Started with tmux
- Unix Tutorial Projects
- tmux mouse mode in macOS
- install tmux with Homebrew
- how to change tmux meta key
- Start tmux instead of login prompt on tty1
tmux
Quite simply, tmux allows you to run multiple terminal command lines at the same time side by side much like putting multiple windows next to each other so you see both simultaneously. It stands for “terminal multiplexer”, a fancy term for something so logical. Here are the basics to get you started with tmux quickly.
First of all, just run tmux. You will very likely have it in your system no matter which Linux or UNIX distribution you’re using. Otherwise you can get it from the tmux website. For MacOS, I suggest using brew package manager.
And you’re in. Not much has changed, but you should see the green bar at the bottom, which is the tmux status bar showing you which window you’re in, date and time, and the hostname of your system. The goodness is in the keyboard commands that you can now use to split the current window into multiple panes, or to create new windows with their own panes. You can then switch between panes and windows with ease.
The way keyboard commands work is by first pressing a shortcut CTRL-B, and then entering a character corresponding to a command. For example, to split the current window or pane into two vertical panes press CTRL-B %. Just press CTRL-B together, then enter the % normally, and it will split.
Here are a few of the basic commands that will have you up and going with tmux with ease:
- CTRL-B % – split into two vertical panes (as mentioned)
- CTRL-B “ – split into two horizontal panes
- CTRL-B z – make the current pane full screen (press again to exit full screen)
- CTRL-B arrow-key – switch between panes with arrow keys. For example
- CTRL-B up-arrow – will switch to the pane above the currently active one.
- CTRL-B c – create a new window. You will notice it indicated in the green status bar under a number.
- CTRL-B number – switch to a window. To switch to a window 0, for example, press CTRL-B 0.
With these shortcuts you can create as many panes and windows as you need, and switch between them.
One more thing though. These sets of windows and panes are known as tmux sessions, and you can actually have multiple of them, and they are saved on the system so that they can be attached to different terminals you can in from.
You can detach from the current session with CTRL-B d, and you’ll end up back on the normal bare command line. Then you can run this to list all of the sessions with its numbers:
You’ll see something like:
Then you can attach to session 0, for example, with this command:
And if you no longer want a particular session you can kill it:
You can see the full breakdown of sessions, their windows, and their panes by issuing this command:
Other useful commands with more information:
- tmux list-keys
- tmux list-commands
- man tmux
See Also
- macOS
- tmux
- tmux reference
- How To Get Started with tmux
- Official tmux page
- Official Brew package manager page
- Useful software for Unix/Linux
- Install latest tmux in macOS
- tmux – terminal multiplexer
- tmux settings
- tmux previews for windows and sessions
- preview windows in tmux
- Change default tmux key
- tmux
- Really cool: tmux sessions survive graphics desktop logout
- How To: Change tmux Meta Key
- Getting Started with tmux
- Basic tmux configuration
- tmux sessions and graphics login to GNOME/KDE
- Getting Started with tmux
- Unix Tutorial Projects
- tmux mouse mode in macOS
- install tmux with Homebrew
- how to change tmux meta key
- Start tmux instead of login prompt on tty1