Try an interactive version of this dialog: Sign up at solve.it.com, click Upload, and pass this URL.
I am a advanced python programmer and systems engineer. I understand linux and know how to administer machine. I have heard of tmux but have never really had the time to learn it. I'd like to use the next 30 minutes to understand the 80% of most commonly used things in tmux.
Great! Let's get you up to speed with tmux efficiently. Since you're an advanced programmer and systems engineer, we can move at a good pace.
First, let me check: do you have tmux installed on your system? If not, it's typically just sudo apt install tmux (Debian/Ubuntu) or brew install tmux (macOS).
Once you confirm, I'll start with the core concept: tmux lets you create sessions that contain windows (like tabs), and windows can be split into panes. Think of it as a persistent terminal multiplexer that survives disconnections.
The most important thing to know first: tmux uses a prefix key (default is Ctrl+b) followed by a command key. So when I write Ctrl+b then c, you press Ctrl+b, release, then press c.
Do you have tmux installed and ready to try some commands?
🧠🧠🧠🧠🧠🧠🧠🧠🧠🧠🧠🧠🧠🧠🧠🧠🧠
Let's start with sessions — the foundation of tmux.
Starting and managing sessions:
- Open a terminal and type:
tmux— this creates a new session - You'll notice a green status bar at the bottom — that's how you know you're inside tmux
Now try these essential session commands:
| Command | What it does |
|---|---|
tmux new -s work |
Create a named session called "work" |
Ctrl+b then d |
Detach from session (it keeps running!) |
tmux ls |
List all sessions |
tmux attach -t work |
Reattach to the "work" session |
Go ahead and try this sequence:
- Create a named session with
tmux new -s practice - Detach with
Ctrl+b then d - List sessions with
tmux ls - Reattach with
tmux attach -t practice
This detach/attach flow is the killer feature — your session survives SSH disconnects, and you can pick up exactly where you left off.
Let me know once you've tried it and how it went!
No! You create new sessions from outside tmux, from your regular terminal.
Here's the flow:
tmux new -s practice— run this from your regular terminal (not inside tmux)- This creates and enters the session
Ctrl+b then d— detach (you're now back in your regular terminal)tmux attach -t practice— run this from your regular terminal to get back in
If you're already inside a tmux session and want to create another one, you'd detach first, then create the new session from outside.
Does that clear it up? Give it a try!
Perfect! Now let's cover windows — these are like tabs in a browser.
While you're inside your tmux session, try these:
| Command | What it does |
|---|---|
Ctrl+b then c |
Create a new window |
Ctrl+b then n |
Go to next window |
Ctrl+b then p |
Go to previous window |
Ctrl+b then 0-9 |
Jump to window number 0-9 |
Ctrl+b then , |
Rename current window |
Try this:
- Create 2-3 windows with
Ctrl+b then c - Navigate between them with
Ctrl+b then nandCtrl+b then p - Notice the status bar at the bottom shows all your windows
The active window will be marked with an asterisk * in the status bar.
Give it a shot and let me know when you're ready for panes!
great got a few windows create c-b n/p for next and previous; c-b , for renaming the session and c-b
Excellent! You've got windows down. Now let's tackle panes — this is where tmux really shines for multitasking.
Panes let you split a single window into multiple sections, so you can see several terminals at once.
Essential pane commands:
| Command | What it does |
|---|---|
Ctrl+b then % |
Split pane vertically (side by side) |
Ctrl+b then " |
Split pane horizontally (top/bottom) |
Ctrl+b then arrow key |
Navigate between panes |
Ctrl+b then x |
Close current pane |
Try this:
- Split your window vertically with
Ctrl+b then % - Split one of those panes horizontally with
Ctrl+b then " - Move around with
Ctrl+b then arrow keys
What layout did you end up with?
Perfect! That's a classic layout — one large pane on the left, two smaller stacked panes on the right.
A few more useful pane commands:
| Command | What it does |
|---|---|
Ctrl+b then z |
Zoom — toggle current pane to fullscreen |
Ctrl+b then { or } |
Swap pane positions |
Ctrl+b then space |
Cycle through preset layouts |
Try Ctrl+b then z while in one of your panes — it temporarily makes it fullscreen. Press it again to zoom back out. Super handy when you need to focus on one thing.
Also try Ctrl+b then space a few times to see different automatic layouts.
How's it feeling so far? Ready to learn about copy mode and scrolling?
great not sure how much I would be using swap panes but that's good to know how it exists - does which pane does it chose to swap with?
Good question! { and } swap with the previous and next pane in tmux's internal ordering (which goes left-to-right, top-to-bottom).
Honestly, it's not super intuitive, which is why most people don't use it much. If you need precise control over pane layout, it's usually easier to just close and recreate them, or use Ctrl+b then space to cycle layouts until you get something close.
Ready to move on to copy mode and scrolling? This is crucial since you can't scroll normally in tmux with your mouse/trackpad by default.
Copy mode and scrolling:
When output scrolls off screen in tmux, you can't just scroll up normally. You need to enter copy mode.
| Command | What it does |
|---|---|
Ctrl+b then [ |
Enter copy mode (scroll with arrow keys or Page Up/Down) |
q |
Exit copy mode |
Space |
Start selection (in copy mode) |
Enter |
Copy selection and exit |
Ctrl+b then ] |
Paste what you copied |
Try this:
- Run
ls -laor any command with output - Enter copy mode with
Ctrl+b then [ - Scroll up with arrow keys or Page Up
- Press
qto exit
The navigation in copy mode uses vi-style keys by default (if you know vi/vim, you can use j/k for up/down, etc.).
Give it a try — can you scroll through your terminal history?
No, it's copying to tmux's internal buffer, not your system clipboard.
So Ctrl+b then ] only pastes within tmux sessions. If you want to paste into another application (like a browser or text editor), you won't be able to use this method by default.
There are ways to integrate tmux with your system clipboard, but that requires configuration. For now, if you need to copy to your system clipboard, you'd typically:
- Use your terminal emulator's selection (mouse highlight + Cmd+C on Mac)
- Or configure tmux to use the system clipboard (involves editing
~/.tmux.conf)
Want to continue with other tmux essentials, or would you like to know how to set up clipboard integration?
Good question! Let me clarify:
When you're in copy mode (Ctrl+b then [), you need to:
- Position your cursor where you want to start selecting
- Press
Spaceto start the selection - Move your cursor to highlight text (you'll see it highlighted)
- Press
Enterto copy and exit copy mode
Then Ctrl+b then ] pastes that text.
Try this:
Ctrl+b then [to enter copy mode- Move to some text you want to copy
- Press
Spaceto start selecting - Use arrow keys to expand the selection
- Press
Enterto copy Ctrl+b then ]to paste it
Did you see the text get highlighted when you pressed Space and moved around?
Hmm, that's odd. Let me troubleshoot:
When you press Space in copy mode, the selection should stay visible as you move the cursor. It sounds like something might be exiting copy mode early.
Try this step-by-step and tell me exactly what you see:
Ctrl+b then [— you should see[0/X]or similar in the top-right corner (this confirms you're in copy mode)- Use arrow keys to move around — does the cursor move?
- Press
Spaceonce — do you still see the[0/X]indicator? - Press an arrow key — does text get highlighted?
What happens at each step? This will help me figure out what's going on.
Interesting. It sounds like Space might not be registering as the selection start key. This can happen if tmux is in emacs mode instead of vi mode, or there's a key binding issue.
Try using mouse mode instead — it's much more intuitive anyway:
- Exit your current tmux session (
Ctrl+b then d) - Run:
tmux set -g mouse on - Reattach to your session
Now you should be able to:
- Scroll with your mouse wheel/trackpad
- Click and drag to select text (it copies automatically to tmux buffer)
- Middle-click or
Ctrl+b then ]to paste
Try enabling mouse mode and see if that works better for you. Does the scrolling work with your mouse now?
Ah, macOS security! You need to grant iTerm2 permission to access the clipboard.
Go to System Settings > Privacy & Security > Automation (or sometimes it's under Accessibility), and look for iTerm2. Make sure it has permission enabled.
Alternatively, you might see a prompt asking for permission — click "Allow" if it appears.
Once you've granted permission, try the mouse selection again in tmux. Were you able to find the setting and enable it?
Great! So now mouse mode is working — you can scroll and select text with your mouse/trackpad?
What part are you unclear about? Is it:
- Why the clipboard permission was needed?
- How the
tmux set -g mouse oncommand worked? - Something else about the copy/paste behavior?
Let me know what you'd like clarified!
both really - since I can regularly copy/paste in term why was tmux not able to access the clipboard. Also why did I need the set-g mouse?
Good questions! Let me break this down:
Why tmux needed clipboard permission:
When you use tmux with mouse mode, tmux itself is trying to interact with the macOS clipboard (not just iTerm2). So macOS sees this as iTerm2 (via tmux) requesting clipboard access, which triggers the security prompt. Without mouse mode, tmux uses its own internal buffer that doesn't touch the system clipboard at all.
Why you needed set -g mouse on:
By default, tmux intercepts all mouse events (clicks, scrolling) so your terminal emulator can't handle them normally. With mouse on, tmux enables:
- Mouse wheel scrolling (instead of needing copy mode)
- Click-and-drag selection that copies to system clipboard
- Click to switch panes/windows
Without it, you're stuck with keyboard-only navigation and the internal buffer copy method (which wasn't working for you with Space).
Does that clarify the two pieces? Want to continue with more tmux features or dive deeper into this?
I think I understand this does that mean when (outside tmux) if I make a mouse selection, it is iterm2 that is intercepting thos calls and copying it to into the clipboard? So all keystrokes/mouse events are intercepted by iterm2 and then keystrokes are forwarded to the process running "inside" tmux?
Exactly! You've got it.
Outside tmux: iTerm2 intercepts mouse selections and handles the clipboard interaction directly. The shell running inside just receives keystrokes.
Inside tmux (without mouse mode): iTerm2 sends everything to tmux, and tmux intercepts mouse events but does nothing with them. So scrolling/selecting doesn't work as expected.
Inside tmux (with mouse mode): iTerm2 → tmux → tmux handles the mouse events itself (scrolling, selecting) and interacts with the system clipboard, which is why it needed permission.
The chain is: Hardware → iTerm2 → tmux → shell/program
Each layer can choose to handle or pass through events.
Ready to continue with more tmux features, or do you want to explore configuration next?
ok so why did the copy paste not work - was the the set -g mouse on or the clipboard permissions that fixed it
It was both, working together:
set -g mouse onenabled tmux to handle mouse selections and attempt to write to the system clipboard- The clipboard permission allowed tmux (via iTerm2) to actually access that clipboard
Without mouse on, tmux wasn't even trying to use the system clipboard — it was using its internal buffer (which requires the Space + arrow keys method, which wasn't working for you).
Without the permission, tmux would try but macOS would block it.
So you needed both pieces for mouse-based copy/paste to work.
Make sense? Ready to move on to the remaining tmux essentials?
Perfect! Let's cover configuration — making your tmux setup persistent.
Right now, set -g mouse on only lasts for your current session. To make settings permanent, you create a config file: ~/.tmux.conf
Here are the most commonly used settings people add:
# Enable mouse
set -g mouse on
# Start window numbering at 1 (instead of 0)
set -g base-index 1
# Increase scrollback buffer
set -g history-limit 10000
# Easier prefix (many people prefer Ctrl+a)
# set -g prefix C-a
# unbind C-b
You don't need to create this now, but when you do, you'll need to either:
- Restart tmux, or
- Run
tmux source-file ~/.tmux.confto reload it
What would you like to cover next? We could do:
- Command mode (running tmux commands directly)
- Killing sessions/windows/panes
- Something else you're curious about?
Yes! You can put it in ~/.config/tmux/tmux.conf instead.
Tmux will look for config in this order:
~/.config/tmux/tmux.conf(XDG standard)~/.tmux.conf(traditional location)
So if you prefer keeping configs organized in .config, that works perfectly.
Want to continue with killing sessions/windows/panes, or explore something else?
A few things to check:
- Is it at
~/.config/tmux/tmux.conf(with thetmuxdirectory)? - Did you reload the config with
tmux source-file ~/.config/tmux/tmux.conf? - Or did you restart tmux completely (detach and kill the session, then start fresh)?
What exactly did you put in the file, and how are you testing whether it's being read?
Great! So it's working now after sourcing?
Let's cover killing/closing things — important for cleanup:
| Command | What it does |
|---|---|
Ctrl+b then x |
Kill current pane (prompts for confirmation) |
Ctrl+b then & |
Kill current window (prompts for confirmation) |
exit or Ctrl+d |
Close current pane/window (normal shell exit) |
tmux kill-session -t name |
Kill a specific session (from outside tmux) |
tmux kill-server |
Kill ALL tmux sessions |
Most of the time you'll just use exit or Ctrl+d to close panes naturally.
What else would you like to cover? We've got about 10-15 minutes left based on your 30-minute goal. Any specific workflows or use cases you're thinking about?
Good question! Here are some useful tmux features we haven't covered yet:
Command mode — Ctrl+b then : lets you type tmux commands directly (like :split-window, :rename-session, etc.)
Resizing panes — Ctrl+b then Ctrl+arrow resizes the current pane (hold Ctrl and press arrow repeatedly)
Session switching — Ctrl+b then s shows an interactive session list you can navigate
Window switching — Ctrl+b then w shows an interactive window/session tree
Last window/pane — Ctrl+b then l (lowercase L) toggles between your last two windows
Synchronize panes — Type the same thing in all panes at once (useful for managing multiple servers)
Any of these sound useful for your workflow? Or is there a specific scenario you're wondering how to handle with tmux?
Right, that's because macOS intercepts Ctrl+arrow for Mission Control and other system shortcuts.
Try this instead: Ctrl+b then hold Ctrl and press arrow keys multiple times — so you're holding both Ctrl and b, release b, then keep holding Ctrl while pressing arrows.
Or use the command mode approach:
Ctrl+b then :to enter command mode- Type
resize-pane -L(left),-R(right),-U(up), or-D(down) - Add a number for bigger steps:
resize-pane -L 5
Does the hold-Ctrl method work, or would you rather use command mode?
Yes! In command mode you can use:
Ctrl+b then :resize-pane -L (or -R, -U, -D)
But if you want vi-style keys for resizing in normal mode, you can add this to your ~/.config/tmux/tmux.conf:
bind -r h resize-pane -L 5
bind -r j resize-pane -D 5
bind -r k resize-pane -U 5
bind -r l resize-pane -R 5
Then you'd use Ctrl+b then h/j/k/l to resize (the -r makes it repeatable, so you can hold the key).
Want to add this to your config and try it out?
this is great thank you. Could you compile a list of all of the keystrokes/commands we have used thus far
Here's your tmux cheat sheet from what we covered:
Sessions:
tmux new -s name— create named sessionCtrl+b then d— detach from sessiontmux ls— list sessionstmux attach -t name— reattach to sessiontmux kill-session -t name— kill specific session
Windows:
Ctrl+b then c— create new windowCtrl+b then n— next windowCtrl+b then p— previous windowCtrl+b then 0-9— jump to window numberCtrl+b then ,— rename windowCtrl+b then w— interactive window listCtrl+b then l— toggle to last windowCtrl+b then &— kill window
Panes:
Ctrl+b then %— split verticallyCtrl+b then "— split horizontallyCtrl+b then arrow— navigate between panesCtrl+b then z— zoom/unzoom paneCtrl+b then space— cycle layoutsCtrl+b then x— kill paneexitorCtrl+d— close pane
Copy/Scroll:
Ctrl+b then [— enter copy modeq— exit copy modeCtrl+b then ]— paste from tmux buffer- Mouse mode handles scrolling/selection automatically
Other:
Ctrl+b then :— command modeCtrl+b then s— interactive session listtmux source-file ~/.config/tmux/tmux.conf— reload config
Want me to add anything else or clarify any of these?
Sessions:
tmux new -s name — create named session Ctrl+b then d — detach from session tmux ls — list sessions tmux attach -t name — reattach to session tmux kill-session -t name — kill specific session
Windows:
Ctrl+b then c — create new window
Ctrl+b then n — next window
Ctrl+b then p — previous window
Ctrl+b then 0-9 — jump to window number
Ctrl+b then , — rename window
Ctrl+b then w — interactive window list
Ctrl+b then l — toggle to last window
Ctrl+b then & — kill window
Panes:
Ctrl+b then % — split vertically
Ctrl+b then " — split horizontally
Ctrl+b then arrow — navigate between panes
Ctrl+b then z — zoom/unzoom pane
Ctrl+b then space — cycle layouts
Ctrl+b then x — kill pane
exit or Ctrl+d — close pane
Copy/Scroll:
Ctrl+b then [ — enter copy mode
q — exit copy mode
Ctrl+b then ] — paste from tmux buffer
Mouse mode handles scrolling/selection automatically
Other:
Ctrl+b then : — command mode
Ctrl+b then s — interactive session list
tmux source-file ~/.config/tmux/tmux.conf — reload config