Boost your productivity with Tmux

As programmers, we always crave for new ways to boost our productivity. For me, one of the most effective tool in the last years has been tmux.

Tmux is a terminal multipler, allowing you to open multiple windows inside a single terminal one, and easily switching between them. You can also split windows in panes and even do some cool pair programming with it.

Tmux can be a bit tricky to use at first, but I suggest you read this excellent book from The Pragmatic Bookshelf:

tmux: Productive Mouse-Free Development

In this excellent book, the author guides us through the configuration of tmux, completely customisable putting our settings inside a file called tmux.conf; finding the perfect setup could take a while, but is definitely worth it.

Finally, this is a short video showing what all this fuss is about and why I love tmux so much:

This entry was posted in Alfredo's Blog. Bookmark the permalink.

20 Responses to Boost your productivity with Tmux

  1. Dominic Bou Samra says:

    Great screencast.

  2. Alfredo Di Napoli says:

    Glad you enjoyed it!

  3. Dominic Bou Samra says:

    I don’t suppose you could Gist your tmux conf? Particularly interested in your powerline status bar.

  4. Jan Machacek says:

    +1: the status bar is really swish!

  5. +1 for gist-ing the tmux conf. Also what’s your .profile/.bashrc? How do you get that great command line thing indicating your git branch (and colours etc)?

  6. Alfredo Di Napoli says:

    Don’t worry guys, I’ll post my whole configuration in the following hours/days. I have a far more complex structure I use to sync my dotfiles across several work environment, but maybe that will be subject for another blog post :)

    Anyway I was eager, so here you are the :

    tmux.conf: https://gist.github.com/adinapoli/4723872
    .vimrc: https://gist.github.com/adinapoli/4723877

    Don’t know how much it could be useful; from my experience, taking someone else config does not make the trick, so I hope you’ll dissect these and use them to find your perfect config :)

    As regards the shell, I use zsh with the excellent Oh My ZSH!
    https://github.com/robbyrussell/oh-my-zsh

  7. Rob says:

    There’s a github project called tmux-powerline for the powerline bar. I’ve actually just switched back to a regular config from it, I found it to be a bit too much for my usually minimal interfaces.

    It’s definitely nice though.

  8. Alfredo Di Napoli says:

    Thanks for the suggestion Rob! Sometimes I definitely like to have “Zen” interfaces,
    and my statusbar is minimal enough to not be too much “cluttering”, but still nicer than the regular one :)

  9. Jeff says:

    Hey Alfredo… excellent stuff. One non-tmux related kudo / question, though: your Mac desktop image is awesome. What is it?

    Thanks!

    jzb

  10. Jon says:

    tmux is great! And tmuxinator makes managing tmux even easier!

  11. Mark Evans says:

    Which method did you use to rebind “Caps Lock” to Crtl-b ?

    I have read about a few others doing it, and they all seem to install http://pqrs.org/macosx/keyremap4macbook/pckeyboardhack.html.en and disable Caps lock from system preferences.

    What did you do?

  12. Alfredo Di Napoli says:

    @Jeff: It’s a russian painter called Afremov!
    @Jon: I was aware of tmuxinator, great tool! I’m not using it just because I wanted to keep my environment (e.g. dotfiles etc etc) a bit more portable, even though if you are on a Mac you have Ruby 1.8 by default :)
    @Mark: I’ve simply used the System Configuration! Go inside Keyboard -> Modifier and you will be prompted with a list of modifier keys: simply remap Caps Lock to act like Ctrl.. it’s super easy! :)

  13. Rob Levin says:

    Thanks for creating this screencast! Obviously, you’re happy with making the step to tmux .. is it worth reading the book, getting used to, etc., for the gains? I ask because in a past life I learned the venerable screen (similar to tmux), but didn’t find myself using it that much.

  14. Rob Levin says:

    Again, thanks for this … so I’m also wondering – if I can create vsplits hsplits in iterm2, and also use Command – Shift – Enter to toggle maximizing and minimizing these, why would I not just use that instead of tmux? I realize it’s probably a bit more expensive but that’s a non issue for me.

    I should mention that I’m an ex vim user and now use ST2 in vintage mode. So your vid reminds me of using splits in vim and Control W’ing back and forth.

    Also, as a front end dev I simply have to go out to a real browser (unless I’m TDD’ing w/phantomjs or nodejs, etc. of course). So I find myself tiling my windows using shiftit (e.g. my browser win on one side, iterm2 session on the other side, editor maybe on another monitory if I’m lucky enough to be working stationary).

    So I guess I’m not yet seeing the reason to make the plunge yet … love to hear more about why I should ;-)

  15. Alfredo Di Napoli says:

    Hi Rob! Well, I can tell you my point of view. The reason I started looking into this “poweruser” stuff a while ago was because I had two things in mind:

    a) Minimise mouse use. I tend to suffer, now and again, of pain in my wrist and forearm, so is essential for me to keep my movements as reduces as possible, focusing them on the keyboard

    b) Portability. This is the key point here. The idea was to create an environment (e.g. tmux, vim, mutt, etc etc) highly portable across *nix platforms. This way, I though, the way I will need to work on Linux, rather than a Mac (and it happened!) I will have my workflow unaffected! In this outlook, try to think what may happen if you decide to change job and end up in a company which uses only Linux boxes. This way, whilst you can bring ST with you, you can’t use iTerm2 anymore! That was my idea; relying on a subset of highly customisable and portable tools which allow me to be productive since day one in any new environment I have to deal with; I just clone my git repo and I’m ready to go! :)

    Does this convince you a little bit more? :) Anyway the book I mentioned is relatively small but it’s worth its money, I suggest you look at it if you want to improve your tmux experience :)

  16. Rob Levin says:

    Hi Alfredo,

    Point a) makes sense – although iterm2 can be pretty much controlled how I described with just keyboard commands for the most part.

    Your point b) regarding portability (and iterm2 not being portable across platforms) is well taken. While I agree it is nice to be able to clone your dotfiles and “just go”, one might argue that this philosophy is sort of a “lowest common denominator approach” since you may forgo certain niceties to osx (or whatever platform you’re on today) to accomodate portability. Not really trying to make an argument but just to play devils advocate ;]

    So not sure I’m yet convinced, but I definitely have something to think about hehe. I may just plow through the book and give it a try; not sure. Either way, your vid and this comment exchange has been quite helpful in getting an overview. Thanks for your time and efforts here! /Rob

  17. Alfredo Di Napoli says:

    No worries, happy of have being useful :)

  18. @Rob: The book is a very good start point. It should part of the tmux documentation itself. So if you want to try it, I totally recommend it.

    @Alfredo: Nice screencast, I haven’t see it completely though :P.

  19. Kamil Politowicz says:

    Hi Alfredo,

    Rob pretty much asked the questions I would, why use tmux, when you have iTerm2. Interestingly, iTerm2 even comes with tmux built-in, so I guess there is a reason. One I can think of is detaching/attaching sessions – iTerm technically saves sessions two, but I don’t think it keeps the processes running when you exit.

    Thanks for the screencast and the book recommendation,
    Kamil

  20. santosharakereantosh says:

    Great. Thank you very much.

    Santosh

Leave a Reply