A Perl script controls Tmux configuration

Split Windows

The split-window statements in lines 47 and 48 with the -h (horizontal) and -v (vertical) options create additional panes in the window by dividing the window horizontally and vertically. Tmux numbers windows and panes from 0 up – but be careful, a frequently used Tmux configuration option changes the start point of the enumeration to 1!

In other words, to address the second pane of the first window in the log4perl session of a newly installed Tmux, line 55 uses log4perl:0.1; it then issues send-keys to run the command for the test suite, followed by a closing C-m (for Return). However, you could just as easily use vagrant ssh to change to a Vagrant VM, as described in the previous issue of this Perl column [4], and ensure that the test suite is running in a virtual cleanroom. Line 51 finds the first two .pm files in the hierarchy of the selected Perl project and passes in their names to the vim editor with the -p option, which displays them in tabs in the left-hand pane (Figure 2).

Figure 2: A Tmux window with an editor, a test suite, and a test file.

Installation

Tmux is included in many distributions' repositories; on Ubuntu, the command

sudo apt-get install tmux

will do the trick. Because the Tmux developers seem to have been very busy of late, users will want to go for version 1.7 at least – or even 1.8 – to take advantage of all the features introduced in this article. If you prefer a more DIY approach, you can pick up the source code [2] and build your own version. The only important dependencies are for libevent (at least 1.4.14 or 2.0) and ncurses. A Bash script available at GitHub [5] automates the build process.

Brian Hogan's book [6] provides useful tips for common tasks – from developer environments through pair programming, wherein two developers in two locations type in different panes in the same session. Even better: If you check the script into your source control system, the next engineer can simply fire up the development environment and start working productively right away.

Mike Schilli

Mike Schilli works as a software engineer with Yahoo! in Sunnyvale, California. He can be contacted at mailto:mschilli@perlmeister.com. Mike's homepage can be found at http://perlmeister.com.

Infos

  1. Listings for this article: http://www.linux-magazine.com/Resources/Article-Code
  2. Tmux: http://tmux.sourceforge.net
  3. Mike Schilli's Tmux configuration: https://github.com/mschilli/dotfiles/blob/master/.tmux.conf
  4. "Perl: Vagrant Vagabond" by Mike Schilli, Linux Magazine, June 2013, pg. 64-67, http://www.linuxpromagazine.com/Issues/2013/151/Perl-Vagrant-Package
  5. Script for a static Tmux build on difficult platforms: https://gist.github.com/ryin/3106801
  6. Hogan, Brian P. tmux: Productive Mouse-Free Development. Pragmatic Bookshelf, 2012

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Table of Contents: 152

    We look at SharePoint integration and show you how to manage Active Directory from Linux. But first, a special story on a dangerous new class of intrusion tools.

  • Perl: Q&A for the Web

    Catalyst is the Ruby on Rails of the Perl universe. When you are developing a web application like a quiz, using the MVC framework is really convenient and helps keep the underlying components cleanly separated.

  • Perl – Vagrant Package

    The Vagrant package provides easy management of virtual machines with VirtualBox as the hypervisor on the command line. Provisioning tools like Puppet let customers try out products in pre-installed environments.

  • Perl: Tricks with Vim

    The Vim editor has any number of tricks for helping you avoid unnecessary typing. In this month’s article, we look at some effort-saving Vim techniques for Perl hackers.

  • Perl: Perl Debugger

    The Perl interpreter, perl, doesn’t often crash, but if it happens, not even the excellent Perl debugger will be able to help you.

comments powered by Disqus

Direct Download

Read full article as PDF:

Price $2.95

News

njobs Europe
What:
Where:
Country:
Njobs Netherlands Njobs Deutschland Njobs United Kingdom Njobs Italia Njobs France Njobs Espana Njobs Poland
Njobs Austria Njobs Denmark Njobs Belgium Njobs Czech Republic Njobs Mexico Njobs India Njobs Colombia