
Pair Programming with tmux A Practical Introduction Vaibhav Bajpai Thursday, April 5, 12 1 iv • Preface Figure 1—tmux as a development environment tmuxWhat Is tmux? tmux is a terminal multiplexer. It lets us use a single environment to launch multiple terminals, or windows, each running its own process or program. tmuxFor example,is a we canterminal launch tmux and load multiplexer up the Vim text editor. We. can It lets then create a new window, load up a database console, and switch back and us useforth between a thesesingle programs all withinenvironment a single session. to launch If you use a modern operating system and a terminal that has tabs, this doesn’t sound like anything new. But running multiple programs simultane- multipleously is only oneterminals, of tmux’s features. We canor divide windowswindows, into horizontal each or vertical panes, which means we can run two or more programs on the runningsame screen its side byown side. And weprocess can do it all without or using theprogram. mouse. We can also detach from a session, meaning we can leave our environment running in the background. If you’ve used GNU-Screen before, you’re familiar Thursday, April 5, 12 with this feature. In many ways, tmux is like GNU-Screen with a lot of extra 2 features, and a much simpler configuration system. And since tmux uses a client-server model, we can control windows and panes from a central location, or even jump between multiple sessions from a single terminal window. This client-server model also lets us create scripts and interact with tmux from other windows or applications. Over the course of this book, we’ll explore all of these features and more. Download from Wow! eBook <www.wowebook.com> report erratum • discuss Outline Installing and Starting tmux Detaching and Attaching Sessions Basics Working with Windows and Panes | Working with Command Mode with shared accounts Pair Programming | with separate accounts Thursday, April 5, 12 3 Installing tmux Debian-based $ sudo apt-get install tmux Mac OS X $ brew install tmux or $ sudo port install tmux Thursday, April 5, 12 4 Starting tmux Starting tmux with a Default Session $ tmux Creating a Named Session $ tmux new-session -s $NAME or $ tmux new -s $NAME Creating a Named Session in the Background $ tmux new-session -d -s $NAME Exiting tmux $ exit Thursday, April 5, 12 5 Attaching & Detaching Sessions Detaching from a Session CTRL-b d Listing existing Sessions $ tmux list-sessions or $ tmux ls Attaching to a Session $ tmux attach -t $NAME Killing Sessions $ tmux kill-session -t $NAME Thursday, April 5, 12 6 Working with Windows Creating a Named Window in New Session $ tmux new -s $SNAME -n $WNAME Creating a Named Window in an Existing Session New Window: CTRL-b C Rename a Window: CTRL-b , Moving between Windows Next Window: CTRL-b n Previous Window: CTRL-b p Choose from a Window List: CTRL-b w Close a Window CTRL-b & Thursday, April 5, 12 7 Working with Panes Create a Vertical Split: CTRL-b % Create a Horizontal Split: CTRL-b “ Cycle through Panes: CTRL-b UP/DOWN/LEFT/RIGHT Cycle through Pane Layouts: CTRL-b SPACEBAR Close a Pane: CTRL-b X Thursday, April 5, 12 8 Command Mode Switch to Command Mode: CTRL-b : Creating a Named Window : new-window -n $NAME Create a Named Window and Start a Process : new-window -n $NAME $PROCESS Switch to Help: CTRL-b ? Thursday, April 5, 12 9 using shared accounts Creating a shared account [...]$ adduser tmux [...]$ su tmux Copying one’s public ssh keys [alice@...]$ ssh-copy-id tmux@server [bob@...]$ ssh-copy-id tmux@server Login as tmux [alice@...]$ ssh tmux@server [bob@...]$ ssh tmux@server Thursday, April 5, 12 10 using shared accounts Shared Session alice: [tmux@...]$ tmux new-session -s share bob: [tmux@...]$ tmux attach -t share Grouped Sessions alice: [tmux@...]$ tmux new-session -s group bob: [tmux@...]$ tmux new-session -t group -s my Thursday, April 5, 12 11 using separate accounts Create a common group $ sudo addgroup tmux Create a folder to hold common sessions $ sudo mkdir /var/tmux $ sudo chgrp tmux /var/tmux $ sudo chmod g+ws /var/tmux Add each member to the common group $ sudo usermod -aG tmux alice $ sudo usermod -aG tmux bob Thursday, April 5, 12 12 using separate accounts Shared Session alice: [alice@...]$ tmux -S /var/tmux/share bob: [bob@...]$ tmux -S /var/tmux/share attach Thursday, April 5, 12 13 References tmux, Productive Mouse-Free Development, Brian P Hogan, Pragmatic Bookshelf 2012 Thursday, April 5, 12 14.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages14 Page
-
File Size-