Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

tmux presentation for code school


Published on

Wonderful class, despite behavior by this code school staff. Presentation intended for instructors, but ended up walking in on 20+ students in a cohort.

Published in: Internet
  • Be the first to comment

  • Be the first to like this

tmux presentation for code school

  1. 1. Full Stack tmux with Tony Narlock for use with Fullstack Academy
  2. 2. We all use different tools • Some use an full fledge IDE like Visual Studio and rarely touch the command line (even do version control via UI) • Some people use Atom / Visual Studio Code and iTerm2 • Some people use gedit and Gnome Terminal • Some incorporate tmux purely for SSH (debugging cloud services on AWS, DigitalOcean, Rackspace) • Some people, use tmux in a way that power of an IDE • Number one rule: use what helps you ship! You don’t have to use it. But today, you’ll know what its for
  3. 3. What this course covers • Rehash of terminal facilities • What tmux is and what its comprised of (internals) • How we see the internals of stuff like tmux (event systems) • Usage • Breeze through the topics discussed at length in The Tao of tmux book (
  4. 4. About me • Open source programmer (wake early to check Bugzilla / GH issues / help on irc, get to work at 9-10AM. Do more at night, some during the day) • Google Summer of Code 2008 student, 2009 mentor • Worked at a Y Combinator company (Boostable W14), an acquihire (Social Amp -> Merkle) at NYU Poly Incubator, Varick Street • Done a lot of node.js in production, as well as Python, Ruby and PHP • Done a ton of front end with ES5, jQuery, Backbone.js, Knockout • Open minded, into technical excellence • Above all: love collaborating and working on teams with people of all experience levels
  5. 5. Some notes about the terminal • All operating systems have a default shell (Bash on MacOS on many linux distros, tcsh on FreeBSD) • Shells also have a scripting dialect, with the basic functionality overlapping with POSIX shell scripting. So they look similar, but their are incompatibilities in there! • Shell frameworks. e.g. oh-my-zsh, presto • Oddities exist due to word of mouth and viral behavior: • For instance, Zsh gained popularity thanks to oh-my-zsh which adds a lot of cozy features. Normal Zsh is about is boring as being dropped in a plain shell without customization • Many people just say “Bash scripting”, when sometimes they mean any shell scripting • “Shell” could refer to scripting, the full terminal application and the PTY within it, the PTY, the PTY in conjunction with the shell (Zsh, Bash). You have to read into the context.
  6. 6. What’s that status line in my coworkers terminal? How can I try tmux? • Right, top image: no tmux • Right, bottom image: inside tmux • To get in, use package manager to install the ‘tmux’ package. e.g. • brew install tmux • sudo apt-get install tmux A terminal using tmux will have a status line at the bottom
  7. 7. Why do people use it? It does two things really well. • Tabs and pane splitting (like in GUI terminals) • Advantage: no gui needed for tmux, can be used via SSH and plain TTY’s • Spawning a lite background daemon to keep workflow running (similar to fg(1)) • Advantage: detaching and reattaching sessions
  8. 8. From the top down
  9. 9. Server • Automatically forked to background when starting tmux the first time • Allows detaching and reattaching the tmux session • No configuration required • Holds sessions
  10. 10. Sessions • Sessions hold windows • Organize individual projects • Are launched automatically on initialization • Can be detached and reattached
  11. 11. Windows • Hold a collection of panes (PTY’s) • Common setups: Vim, Gulp / Grunt watchers, SSH sessions, deployment via fabric, heroku, elastic beanstalk, git
  12. 12. Panes (PTY's) • A terminal within a terminal • PTY holding Zsh, Bash, etc. • Vim/emacs/nano/pico • File watching / linters / gulp / grunt / dev servers (./ runserver)
  13. 13. Inside tmux (advanced stuff) • tmux is built upon libevent, a library which abstracts system events via callbacks • allows tmux to keep the users PTY processes daemon-ized • This event system also is used in Chromium (Google Chrome). Node.js uses a similar system, libuv.
  14. 14. Command Pattern • tmux abstracts out behavior into a system of commands • Patterns like these are often given examples of in OOP, but they can exist in C as well. • Due to the lack of OOP patterns, helper macros are used to create lists of objects (BSD’s queue.h is vendor’d in) • tmux separates all behavior into cmd, via both data structures and files (cmd_*.c) • they are declared in the source as cmd_entry.
  15. 15. Portability • Since tmux is written in C, it must use compatibility measures to work across POSIX-like systems (Unlike languages like node.js, which provide standard libraries that already did the work of abstracting subtle differences in OS) • tmux uses autotools to check for compiler features, scan for headers (.h files) signature definitions for libraries as well as the built .so libs themselves, so tmux can link against them • The process of using build systems like autotools assures any user can clone the codebase and build on any system which have the libraries themselves
  16. 16. Be thankful to be in JS, Python and Ruby • It abstracts out a lot of the banality of C • Unlike JS and Python, it’s harder to say who’s an expert C/C++ programmer. (Do you go by who writes the popular books on “best practices”, e.g. Herb Sutter, Scott Meyers, software actually ships e.g. Nicholas Marriott, John Carmack?) • Learning more about C is a great extracurricular because we learn more about how like Node (C++), Python (C), and Ruby (C) is brought to us.
  17. 17. What we covered • A peek at tmux via its objects (the server, sessions, windows and panes) and some of its internals (events, compatibility, patterns). • Go back to coding and pick the tools you can ship with! • Check out my section of The Tao of tmux where I cover Terminal Fundamentals for a more detailed overview of the responsibilities of the shell.