Try an interactive version of this dialog: Sign up at solve.it.com, click Upload, and pass this URL.

Prompt: 91

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.

Assistant: 288

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?

Prompt: 7

yes let's do it.

Assistant: 367

🧠🧠🧠🧠🧠🧠🧠🧠🧠🧠🧠🧠🧠🧠🧠🧠🧠

Let's start with sessions — the foundation of tmux.

Starting and managing sessions:

  1. Open a terminal and type: tmux — this creates a new session
  2. 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:

  1. Create a named session with tmux new -s practice
  2. Detach with Ctrl+b then d
  3. List sessions with tmux ls
  4. 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!

Prompt: 15

do I create the new session inside tmux?

Assistant: 199

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!

Prompt: 7

yup let's continue

Assistant: 306

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:

  1. Create 2-3 windows with Ctrl+b then c
  2. Navigate between them with Ctrl+b then n and Ctrl+b then p
  3. 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!

Prompt: 13

is it cmd on macos or ctrl?

Assistant: 61

It's Ctrl on macOS too, not Cmd.

So on Mac, it's still Ctrl+b as the prefix key (even though many Mac shortcuts use Cmd).

Ready to continue with panes?

Prompt: 51

great got a few windows create c-b n/p for next and previous; c-b , for renaming the session and c-b for picking a specific window

Assistant: 273

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:

  1. Split your window vertically with Ctrl+b then %
  2. Split one of those panes horizontally with Ctrl+b then "
  3. Move around with Ctrl+b then arrow keys

What layout did you end up with?

Prompt: 22

ok so I have a split vertical and the right pane is split horizontally

Assistant: 238

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?

Prompt: 45

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?

Assistant: 181

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.

Prompt: 6

lets move on

Assistant: 312

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:

  1. Run ls -la or any command with output
  2. Enter copy mode with Ctrl+b then [
  3. Scroll up with arrow keys or Page Up
  4. Press q to 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?

Prompt: 10

is this copying to a clipboard?

Assistant: 229

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?

Prompt: 25

not yet - not sure what was copied and how I get to the copied content

Assistant: 250

Good question! Let me clarify:

When you're in copy mode (Ctrl+b then [), you need to:

  1. Position your cursor where you want to start selecting
  2. Press Space to start the selection
  3. Move your cursor to highlight text (you'll see it highlighted)
  4. Press Enter to copy and exit copy mode

Then Ctrl+b then ] pastes that text.

Try this:

  1. Ctrl+b then [ to enter copy mode
  2. Move to some text you want to copy
  3. Press Space to start selecting
  4. Use arrow keys to expand the selection
  5. Press Enter to copy
  6. Ctrl+b then ] to paste it

Did you see the text get highlighted when you pressed Space and moved around?

Prompt: 27

It doesn't seem to copy any thing - moment I hit space it seems to dissappear

Assistant: 220

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:

  1. Ctrl+b then [ — you should see [0/X] or similar in the top-right corner (this confirms you're in copy mode)
  2. Use arrow keys to move around — does the cursor move?
  3. Press Space once — do you still see the [0/X] indicator?
  4. Press an arrow key — does text get highlighted?

What happens at each step? This will help me figure out what's going on.

Prompt: 27

1 works 2 works 3 doesn't seem to do anything 4 no highlighted text

Assistant: 237

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:

  1. Exit your current tmux session (Ctrl+b then d)
  2. Run: tmux set -g mouse on
  3. 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?

Prompt: 99

I am seeing an error from iterm2

pasted_image

Assistant: 147

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?

Prompt: 0

Assistant: 46

It looks like you sent an empty message. Are you still working on enabling the clipboard permission in macOS settings, or did you run into another issue?

Prompt: 18

ok so that worked - I don't understand what happened here.

Assistant: 109

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 on command worked?
  • Something else about the copy/paste behavior?

Let me know what you'd like clarified!

Prompt: 51

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?

Assistant: 319

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?

Prompt: 109

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?

Assistant: 250

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?

Prompt: 39

ok so why did the copy paste not work - was the the set -g mouse on or the clipboard permissions that fixed it

Assistant: 204

It was both, working together:

  1. set -g mouse on enabled tmux to handle mouse selections and attempt to write to the system clipboard
  2. 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?

Prompt: 7

ok let's move on.

Assistant: 318

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:

Copied!
# 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.conf to 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?

Prompt: 10

can this live in .config?

Assistant: 133

Yes! You can put it in ~/.config/tmux/tmux.conf instead.

Tmux will look for config in this order:

  1. ~/.config/tmux/tmux.conf (XDG standard)
  2. ~/.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?

Prompt: 21

I created the tmux.conf it doesn't seem to be getting read

Assistant: 136

A few things to check:

  1. Is it at ~/.config/tmux/tmux.conf (with the tmux directory)?
  2. Did you reload the config with tmux source-file ~/.config/tmux/tmux.conf?
  3. 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?

Prompt: 15

ok I missed sourcing the file - let's continue

Assistant: 273

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?

Prompt: 12

what have I not asked you about?

Assistant: 277

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?

Prompt: 19

so resizing panes doesn't work on macos with ctrl-up arrow

Assistant: 219

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?

Prompt: 12

is there a vi key binding here?

Assistant: 235

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:

Copied!
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?

Prompt: 37

this is great thank you. Could you compile a list of all of the keystrokes/commands we have used thus far

Assistant: 561

Here's your tmux cheat sheet from what we covered:

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

Want me to add anything else or clarify any of these?

Note: 423

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:

Copied!
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:

Copied!
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:

Copied!
Ctrl+b then [ — enter copy mode
q — exit copy mode
Ctrl+b then ] — paste from tmux buffer
Mouse mode handles scrolling/selection automatically

Other:

Copied!
Ctrl+b then : — command mode
Ctrl+b then s — interactive session list
tmux source-file ~/.config/tmux/tmux.conf — reload config