How can I limit iTerm2 text selection to a single tmux pane?

Solution 1:

I had the same question and it was hard to google answer.

Choosing Edit > Selection Respects Soft Boundaries works fine.

Solution 2:

tmux panes are simply logical windows emulated within a single text field. This means that the OSX system-level text handling does not recognize the tmux panes as separate fields. To get the behavior you desire you'll need to override or simply not use the default OS behavior.

Instead, you'll need to learn to use tmux's own internal selection/copy functionality (Copy Mode). This respects pane boundaries and enables selection/move/copy using non-system-hotkey presses.

See this cheat sheet for info on how to use it: https://tmuxcheatsheet.com/

EDIT: Ah, then you need to enable mouse mode. See https://stackoverflow.com/questions/11832199/tmux-set-g-mouse-mode-on-doesnt-work#33336609 and similar answers