@celestineschrunk
@lemmy.runInspired by another post here -> https://lemmy.run/post/46724
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.
To install Tmux, follow the instructions below:
brew install tmux
sudo apt-get install tmux
sudo dnf install tmux
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.
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 allow you to split the current window into multiple sections, each running its own command. Here are some commonly used pane commands:
Ctrl + b
followed by %
Ctrl + b
followed by "
Ctrl + b
followed by an arrow key (e.g., Ctrl + b
followed by Left Arrow
)Ctrl + b
followed by Ctrl + arrow key
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:
Ctrl + b
followed by c
Ctrl + b
followed by a number key (e.g., Ctrl + b
followed by 0
to switch to window 0)Ctrl + b
followed by &
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.
Ctrl + b
followed by d
tmux list-sessions
tmux attach-session -t <session-name>
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
:
.tmux.conf
file in your home directory.set-option -g prefix C-a
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
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.