Skip to content

Instantly share code, notes, and snippets.

@Darkflib
Created December 9, 2024 17:04
Show Gist options
  • Save Darkflib/0d063aae314a101808ecbb3226bc4d52 to your computer and use it in GitHub Desktop.
Save Darkflib/0d063aae314a101808ecbb3226bc4d52 to your computer and use it in GitHub Desktop.

Here's a quick reference for Tmux, covering sessions, panes, and windows along with the command you mentioned.

Tmux Basics

  • Start a new session:
    tmux new -s <session_name>
  • Attach to an existing session:
    tmux attach -t <session_name>
  • List all sessions:
    tmux ls
  • Kill a session:
    tmux kill-session -t <session_name>
  • Create a new session (or attach if it exists):
    tmux new -s mike -A

Windows

  • Create a new window:
    tmux new-window
    or from within Tmux:
    Ctrl+b c
  • Switch between windows:
    • Next window: Ctrl+b n
    • Previous window: Ctrl+b p
    • Directly by number: Ctrl+b <number>
  • Rename a window:
    Ctrl+b ,  # then type the new name
  • Kill the current window:
    tmux kill-window

Panes

  • Split pane horizontally:
    Ctrl+b "
  • Split pane vertically:
    Ctrl+b %
  • Switch between panes:
    • Next pane: Ctrl+b o
    • Manually: Ctrl+b <arrow_key>
  • Resize a pane: Hold Ctrl+b, then press : and type resize-pane -D, resize-pane -U, resize-pane -L, or resize-pane -R for resizing.
  • Break a pane into a new window:
    Ctrl+b !  # Detach the current pane into a new window
  • Close the current pane:
    Ctrl+d
    or within the pane:
    exit

Session and Window Navigation

  • List windows:
    Ctrl+b w  # Shows a list of windows in the session
  • Kill a specific window:
    tmux kill-window -t <window_number_or_name>
  • Detach from the session:
    Ctrl+b d
  • Attach to a session after detaching:
    tmux attach -t <session_name>

This should cover your most commonly used commands in Tmux, including tmux new -s mike -A for session handling and splitting/controlling windows and panes. Let me know if you need more details!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment