How to Use Tmux
Tmux is a powerful terminal multiplexer that allows you to manage multiple terminal sessions within a single window. In this guide, we will cover the basic usage of Tmux.
Installation
To install Tmux, you can use package managers like apt, yum, or brew. For example, on Ubuntu, you can run:
sudo apt-get install tmux
Starting a New Tmux Session
To start a new Tmux session, open your terminal and type:
tmux new-session -s <session-name>
Replace <session-name> with the desired name for your session.
Basic Tmux Commands
Here are some basic Tmux commands you can use:
- Ctrl-b d: Detach from the current session
- Ctrl-b %: Split the current pane vertically
- Ctrl-b “: Split the current pane horizontally
- Ctrl-b arrow: Switch to the pane in the specified direction
- Ctrl-b z: Zoom in/out of the current pane
- Ctrl-b c: Create a new window
- Ctrl-b n: Switch to the next window
- Ctrl-b p: Switch to the previous window
- Ctrl-b l: Switch to the last window
- Ctrl-b &: Kill the current window or pane
Attaching and Detaching Sessions
To attach to an existing Tmux session, run:
tmux attach-session -t <session-name>
Replace <session-name> with the name of the session you want to attach to.
To detach from a Tmux session, press Ctrl-b d.
Conclusion
With Tmux, you can enhance your productivity by managing multiple terminal sessions efficiently. Practice using these basic commands to become proficient with Tmux. Happy coding!