Top Banner
tmux - Terminal Multiplexer Mark Volkmann [email protected]
22

tmux - Terminal Multiplexer - Mark Volkmann

Jan 20, 2023

Download

Documents

Khang Minh
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: tmux - Terminal Multiplexer - Mark Volkmann

tmux - Terminal Multiplexer

Mark [email protected]

Page 2: tmux - Terminal Multiplexer - Mark Volkmann

tmux

Overview

Dramatically expands what can be donewith terminal windowsAlternative to older program named “screen”Often used for interactive server sessions

that can survive network disconnections

2

Page 3: tmux - Terminal Multiplexer - Mark Volkmann

tmux

Book

tmux: Productive Mouse-Free DevelopmentBrian P. Hogan

Pragmatic Programmers

3

Page 4: tmux - Terminal Multiplexer - Mark Volkmann

tmux

For You?

Do you work in a Unixey environment?Do you frequently use terminal windows?Do you value using keyboard shortcuts?

4

Page 5: tmux - Terminal Multiplexer - Mark Volkmann

tmux

tmux Commands

Large number of themMany ways to execute

command-line

shell script

command mode in tmux client

keyboard shortcut in tmux client

tmux configuration file

5

Page 6: tmux - Terminal Multiplexer - Mark Volkmann

tmux

Key Bindings

Prefix keyC-b by default; many change to C-a

Meta keyabbreviated as M; cmd-option on Mac

Commandslist-keys or prefix ?

bind-key [-r] {key} {command}

-r allows repeated used without prefix

unbind-key {key}

6

Page 7: tmux - Terminal Multiplexer - Mark Volkmann

tmux

Terminology

serverclientsessionwindowpanestatus bar

7

Page 8: tmux - Terminal Multiplexer - Mark Volkmann

tmux

Sample Session

Demo time!

8

Page 9: tmux - Terminal Multiplexer - Mark Volkmann

tmux

Session Actions

newdetachattachlistrenameswitch - one being displayedkill

9

Page 10: tmux - Terminal Multiplexer - Mark Volkmann

tmux

Window Actions

newrenameswitch - one being viewedlistmove - to a different sessionkill

10

Page 11: tmux - Terminal Multiplexer - Mark Volkmann

tmux

Pane Actions

new - via splitswitch - one that is activechange layoutresizerotate - to change position of allswap - to change position of twomove - to different windowexecute command - from a script into a specific panekill

11

Page 12: tmux - Terminal Multiplexer - Mark Volkmann

tmux

Predefined Pane Layouts ...

even-horizontal

12

even-vertical

Page 13: tmux - Terminal Multiplexer - Mark Volkmann

tmux

... Predefined Pane Layouts

main-horizontalmain-verticaltiled

13

Page 14: tmux - Terminal Multiplexer - Mark Volkmann

tmux

Buffers

Each pane has a buffer that storescommands entered and their output

has a limited size that defaults to 2000 lines

Enter “copy mode” toscroll through and copy linesEach copy adds a “paste buffer” to a stack

has a limited size that defaults to 20

14

Page 15: tmux - Terminal Multiplexer - Mark Volkmann

tmux

Copy Mode Actions

enter copy modeexit copy modemove cursorcopy selected textcopy all visible textlist paste buffersview paste buffer contents

save paste buffercontent to a filepaste text froma paste bufferchange paste bufferstack sizedelete one paste bufferdelete all paste buffers

15

Page 16: tmux - Terminal Multiplexer - Mark Volkmann

tmux

Configuration Options

Three kindsserver

session

window

Option scopeglobal

specific session

specific window

Actionsset option

show option

16

Page 17: tmux - Terminal Multiplexer - Mark Volkmann

tmux

Configuration Files

Looks for ~/.tmux.conf firstThen looks for /etc/tmux.confLet’s examine mine!

17

Page 18: tmux - Terminal Multiplexer - Mark Volkmann

tmux

Scripting

Consider creating one setup script for each projectCreates a new project session if it doesn’t exist

creates windows

splits them into panes

starts commands in some windowsex. editor, file watching apps, ssh, ...

Otherwise, attaches to existing sessionLet’s examine one of mine!

18

Page 19: tmux - Terminal Multiplexer - Mark Volkmann

tmux

Collaboration

ssh to a remote serverStart a tmux session thereAsk others to

ssh to same remote server

attach to same tmux session

Collaborate!

19

Page 20: tmux - Terminal Multiplexer - Mark Volkmann

tmux

Multiple Monitors

Run client in first monitor attached to main sessionRun client in other monitors attached to a new session that is “grouped” with main sessionAllows each client to viewa different window in main sessionSet window option “aggressive-resize” to “on”

allows each client window to be a different size

20

Page 21: tmux - Terminal Multiplexer - Mark Volkmann

tmux

Mac Specific Advice

Use iTerm2Change some System PreferencesChange some iTerm2 PreferencesFor details, see my OCI SETT article

http://sett.ociweb.com/sett/settJan2013.html

21

Page 22: tmux - Terminal Multiplexer - Mark Volkmann

tmux

Thanks For Listening!

[email protected]

22