Tmux Cheatsheet: Navigating Sessions Like a Pro ๐
Are you tired of forgetting how to use tmux on Linux? Look no further! This cheatsheet will help you master tmux session management and navigation.
What is Tmux? ๐
Tmux (Terminal Multiplexer) is a powerful tool that allows you to create multiple terminal sessions within a single window. It’s especially useful for remote work, as it enables you to detach from and reattach to sessions without losing your work.
Session Management ๐
Create a new session ๐
tmux new-session -s session_name
# or
tmux new -s session_name
-s: Specify a session name
List sessions ๐
tmux list-sessions
# or
tmux ls
Attach to a session ๐
tmux attach-session -t session_name
# or
tmux attach -t session_name
-t: Target session name
Detach from a session ๐
tmux detach
Or use the key binding: Ctrl-b d
Switch between sessions ๐
tmux switch-client -t session_name
-t: Target session name
Common Key Bindings ๐
Ctrl-b d: Detach from current sessionCtrl-b s: List sessionsCtrl-b $: Rename current sessionCtrl-b (: Switch to previous sessionCtrl-b ): Switch to next session
Pro Tips for Linux Users ๐
-
Start tmux automatically on SSH login by adding the following to your
.bashrcor.zshrc:if [[ -z "$TMUX" ]] && [ "$SSH_CONNECTION" != "" ]; then tmux attach-session -t ssh_tmux || tmux new-session -s ssh_tmux fi -
Create a tmux configuration file (
~/.tmux.conf) for custom settings:# Example: Change prefix key to Ctrl-a set -g prefix C-a unbind C-b bind C-a send-prefix -
Use tmux plugins for enhanced functionality (install with Tmux Plugin Manager - TPM)
Remember: Practice regularly to build muscle memory for tmux commands and key bindings!
Conclusion ๐
With this cheatsheet, you’ll never forget how to navigate between tmux sessions or how to detach and attach again. Keep it handy, and soon you’ll be managing your terminal sessions like a pro!