tmux 2
Productive Mouse-Free Development
by Brian P. Hogan
Version: P1.0 (November 2016)
Copyright © 2016 The Pragmatic Programmers, LLC. This book is licensed to the individual who
purchased it. We don't copy-protect it because that would limit your ability to use it for your own
purposes. Please don't break this trust—you can use this across all of your devices but please do not
share this copy with other members of your team, with friends, or via file sharing services. Thanks.
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as
trademarks. Where those designations appear in this book, and The Pragmatic Programmers, LLC was
aware of a trademark claim, the designations have been printed in initial capital letters or in all capitals.
The Pragmatic Starter Kit, The Pragmatic Programmer, Pragmatic Programming, Pragmatic Bookshelf
and the linking g device are trademarks of The Pragmatic Programmers, LLC.
Every precaution was taken in the preparation of this book. However, the publisher assumes no
responsibility for errors or omissions, or for damages that may result from the use of information
(including program listings) contained herein.
About the Pragmatic Bookshelf
The Pragmatic Bookshelf is an agile publishing company. We’re here because we want to improve the
lives of developers. We do this by creating timely, practical titles, written by programmers for
programmers.
Our Pragmatic courses, workshops, and other products can help you and your team create better
software and have more fun. For more information, as well as the latest Pragmatic titles, please visit us
at http://pragprog.com.
Our ebooks do not contain any Digital Restrictions Management, and have always been DRM-free. We
pioneered the beta book concept, where you can purchase and read a book while it’s still being written,
and provide feedback to the author to help make a better book for everyone. Free resources for all
purchasers include source code downloads (if applicable), errata and discussion forums, all available on
the book's home page at pragprog.com. We’re here to make your life easier.
New Book Announcements
Want to keep up on our latest titles and announcements, and occasional special offers? Just create an
account on pragprog.com (an email address and a password is all it takes) and select the checkbox to
receive newsletters. You can also follow us on twitter as @pragprog.
About Ebook Formats
If you buy directly from pragprog.com, you get ebooks in all available formats for one price. You can
synch your ebooks amongst all your devices (including iPhone/iPad, Android, laptops, etc.) via Dropbox.
You get free updates for the life of the edition. And, of course, you can always come back and re-
download your books when needed. Ebooks bought from the Amazon Kindle store are subject to
Amazon's polices. Limitations in Amazon's file format may cause ebooks to display differently on
different devices. For more information, please see our FAQ at pragprog.com/frequently-asked-
questions/ebooks. To learn more about this book and access the free resources, go to
https://pragprog.com/book/bhtmux2, the book's homepage.
Thanks for your continued support,
Dave Thomas and Andy Hunt
The Pragmatic Programmers
The team that produced this book includes: Susannah Davidson Pfalzer (editor),
Nicole Abramowitz (copyeditor), Gilson Graphics (layout),
Janet Furlow (producer)
For customer support, please contact support@pragprog.com.
For international rights, please contact rights@pragprog.com.
Table of Contents
Acknowledgments
Preface
What Is tmux?
Who Should Read This Book
What’s in This Book
Changes in the Second Edition
What You Need
Conventions
Online Resources
1. Learning the Basics
Installing tmux
Starting tmux
The Command Prefix
Detaching and Attaching Sessions
Working with Windows
Working with Panes
Working with Command Mode
What’s Next?
For Future Reference
2. Configuring tmux
Introducing the .tmux.conf File
Customizing Keys, Commands, and User Input
Visual Styling
Customizing the Status Line’s Content
What’s Next?
For Future Reference
3.
Scripting Customized tmux Environments
Creating a Custom Setup with tmux Commands
Using tmux Configuration for Setup
Managing Configuration with tmuxinator
What’s Next?
For Future Reference
4. Working With Text and Buffers
Scrolling Through Output with Copy Mode
Copying and Pasting Text
Working with the Clipboard on Linux
Using OS X Clipboard Commands
What’s Next?
For Future Reference
5. Pair Programming with tmux
Pairing with a Shared Account
Using a Shared Account and Grouped Sessions
Quickly Pairing with tmate
Pairing with Separate Accounts and Sockets
What’s Next?
For Future Reference
6. Workflows
Working Effectively with Panes and Windows
Managing Sessions
tmux and Your Operating System
Extending tmux with Plugins
What’s Next?
For Future Reference
A1. Our Configuration
Copyright © 2016, The Pragmatic Bookshelf.
What readers are saying about tmux 2:
Productive Mouse-Free Development
A must-have book for anyone that uses the command line daily. This is a book I have been
recommending since it was first published, and I will definitely recommend it again!
→ Jeff Holland
Senior software engineer, Ackmann & Dickenson
The tricks mentioned in this book completely changed my workflow. I recommend this book to
anyone who is looking to improve their workflow on the command line.
→ Jacob Chae
Software engineer, Assurant
The author always has something amazing in store for you: custom commands to fire up your
development environment, customizing it, pair programming, and many use cases. This book
makes you step up your game in becoming a more efficient developer.
→ Peter Perlepes
Software engineer, adaplo
I had zero tmux experience before picking up the book, and I could use tmux in my day-to-day
routine after reading the book.
→ Nick McGinness
Software engineer, Direct Supply