Tmux is a terminal multiplexer that allows you to run multiple terminal sessions within a single window. It enhances your productivity by enabling you to create and manage multiple panes and windows, detach and reattach sessions, and more. In this tutorial, we'll cover the basic usage of Tmux.
Installation
To install Tmux, follow the instructions below:
macOS
brew install tmux
Ubuntu/Debian
sudo apt-get install tmux
CentOS/Fedora
sudo dnf install tmux
Starting a Tmux Session
To start a new Tmux session, open your terminal and enter the following command:
tmux new-session
This will create a new Tmux session with a single window.
Key Bindings
Tmux uses key bindings to perform various actions. By default, the prefix key is Ctrl + b, which means you need to press Ctrl + b before executing any command.
For example, to split the current window vertically, you would press Ctrl + b followed by %.
Panes
Panes allow you to split the current window into multiple sections, each running its own command. Here are some commonly used pane commands:
Split the window vertically:Ctrl + b followed by %
Split the window horizontally:Ctrl + b followed by "
Switch between panes:Ctrl + b followed by an arrow key (e.g., Ctrl + b followed by Left Arrow)
Resize panes:Ctrl + b followed by Ctrl + arrow key
Windows
Windows in Tmux are like tabs in a web browser or editor. They allow you to have multiple terminal sessions within a single Tmux session. Here are some window commands:
Create a new window:Ctrl + b followed by c
Switch between windows:Ctrl + b followed by a number key (e.g., Ctrl + b followed by 0 to switch to window 0)
Close the current window:Ctrl + b followed by &
Session Management
Tmux allows you to detach and reattach sessions, which is useful when you need to switch between different machines or disconnect from your current session.
Detach from the current session:Ctrl + b followed by d
List all sessions:tmux list-sessions
Reattach to a detached session:tmux attach-session -t <session-name>
Configuration
Tmux can be customized by creating a .tmux.conf file in your home directory. You can modify key bindings, customize the status bar, and more. Here's an example of how to change the prefix key to Ctrl + a:
Create or edit the .tmux.conf file in your home directory.
Add the following line to the file: set-option -g prefix C-a
Save the file and exit.
After making changes to your configuration file, you can either restart Tmux or reload the configuration by running the following command within a Tmux session:
tmux source-file ~/.tmux.conf
Conclusion
Congratulations! You've learned the basics of using Tmux. With Tmux, you can work more efficiently by managing multiple terminal sessions within a single window. Explore more features and commands by referring to the Tmux documentation.
Thanks for that!
Maybe you can help me with something? Years ago I used a program that would make it so my terminal/tmux screen was accessable from anywhere and it would drop down from the top of the screen. You were able to configure the window to be slightly transparent. Somehow I think of the word "gecko" when trying to remember.... I realize this might not be much to go on tho haha