21
Starting Tmux

Introduction to Tmux - Codementor Tmux Office Hours Part 1

Embed Size (px)

DESCRIPTION

What is tmux? tmux is a terminal multiplexer: it enables a number of terminals (or windows), each running a separate program, to be created, accessed, and controlled from a single screen. It is a popular secret weapon of many experienced developers. Codementor expert Bruno Sutic is the creator of various Tmux plugins. In this Office Hours Bruno will talk about beginning with tmux, but also about more advanced use cases and best practices. Here's a list of topics Bruno will cover: why use tmux tmux basics best practices tmux plugin manager - 'TPM' tmux-resurrect - why use it tmux-copycat + tmux-yank + tmux-open (how to work with these plugins)

Citation preview

Page 1: Introduction to Tmux - Codementor Tmux Office Hours Part 1

Starting Tmux

Page 2: Introduction to Tmux - Codementor Tmux Office Hours Part 1

Problem with the vanilla console app?

• managing (huge) number of terminals

• example terminals for just one project

Page 3: Introduction to Tmux - Codementor Tmux Office Hours Part 1

Problem with the vanilla console app?

• example terminals multiple projects

Page 4: Introduction to Tmux - Codementor Tmux Office Hours Part 1

Solution?Tmux - terminal multiplexer

• “Core” features:

• multiple windows

• window splits (horizontal & vertical)

• sessions (groups of windows)

• persistant env

• Other advanced features

Page 5: Introduction to Tmux - Codementor Tmux Office Hours Part 1

Installing Tmux

• Mac$ brew install tmux$ brew install reattach-to-user-namespace (fixes pbpaste)

• Linux$ apt-get install -y tmux

Page 6: Introduction to Tmux - Codementor Tmux Office Hours Part 1

Recommended configuration• ~/.tmux.conf - tmux config file

• remap default “prefix” from Ctrl-b to Ctrl-a

• set -g prefix C-a # in .tmux.conf

• remap Caps Lock to Ctrl (on a system level)

Page 7: Introduction to Tmux - Codementor Tmux Office Hours Part 1

Demo: starting tmux

• just type $ tmux

Page 8: Introduction to Tmux - Codementor Tmux Office Hours Part 1

Demo: creating new windows

• prefix + c

Page 9: Introduction to Tmux - Codementor Tmux Office Hours Part 1

Demo: navigating windows

• previous window: prefix + p • next window: prefix + n • specific window: prefix + <num>

Page 10: Introduction to Tmux - Codementor Tmux Office Hours Part 1

Demo: splitting windows

• vertical split: prefix + % • horizontal split: prefix + “

*unusual choiceof keys

Page 11: Introduction to Tmux - Codementor Tmux Office Hours Part 1

Demo: split movement

• prefix + <arrow key>

Page 12: Introduction to Tmux - Codementor Tmux Office Hours Part 1

Demo: creating sessions

• prefix + :new -s session_name *veryinconvenient

Page 13: Introduction to Tmux - Codementor Tmux Office Hours Part 1

Demo: switching sessions

• switch session: prefix + s • navigate sessions: j, k (or arrow keys)

Page 14: Introduction to Tmux - Codementor Tmux Office Hours Part 1

Demo: detaching tmux

• detach: prefix + d • attach: $ tmux attach

Page 15: Introduction to Tmux - Codementor Tmux Office Hours Part 1

Tmux demo roundup• manipulating windows

• manipulating splits

• manipulating sessions

• some quirky defaults => Tmux configuration

Page 16: Introduction to Tmux - Codementor Tmux Office Hours Part 1

Basic Tmux configuration• very configurable

• any key-binding can be changed

• “community standards” - things everyone has in their .tmux.conf

Page 17: Introduction to Tmux - Codementor Tmux Office Hours Part 1

Configuration via plugins• tmux-sensible

- handles tmux quirks and boilerplate configuration

• tmux-pain-control- convenient basic key bindings

• tmux-sessionist- better session handling

Page 18: Introduction to Tmux - Codementor Tmux Office Hours Part 1

Installing plugins

Page 19: Introduction to Tmux - Codementor Tmux Office Hours Part 1

Plugin benefits

• less tmux quirks • more vim :)

Page 20: Introduction to Tmux - Codementor Tmux Office Hours Part 1

Next steps?• look up tmux copy mode (scrollback)

• $ man tmux

• use tmux daily

• tmux book

• more pluginshttps://github.com/tmux-plugins

Page 21: Introduction to Tmux - Codementor Tmux Office Hours Part 1

Questions?