Skip to content

Instantly share code, notes, and snippets.

@blip-lorist
Last active January 26, 2017 17:43
Show Gist options
  • Save blip-lorist/6e5a67809b25b88f6b1d to your computer and use it in GitHub Desktop.
Save blip-lorist/6e5a67809b25b88f6b1d to your computer and use it in GitHub Desktop.
Getting started with tmux

Tmux Setup Guide

Why even?

  • Workflow management: Tired of opening the same directories / windows / panes when working on a project? You can save it all to a session and return at any time.
  • Terminal window and pane management (handy when using vim)
  • Session management: run time-consuming terminal processes in one session, and go do other stuff in other sessions

Installation (OS X)

brew install tmux

Configuration

You can configure all of your tmux settings in ~/.tmux.conf. If it doesn't exist, go ahead and create it.

By default, the prefix for all tmux commands is CTRL+B. However, many people switch the prefix to CTRL+A because they find it easier to type.

Here's are some things in my .tmux.conf file I find helpful:

unbind C-b  

set -g prefix C-a changing the prefix over to CTRL+A

bind-key C-a last-window cycle between you last windows by using your prefix twice

https://blog.no-panic.at/2015/04/21/set-tmux-pane-title-on-ssh-connections/ Label your tmux panes with the remote servers you're connected to

Getting Started

Here's a quick way to see what's possible with tmux:

  1. Launch Terminal

  2. Type tmux new -s some_project_name to begin. This creates a new session for a project you're working on.

  3. Let's divide your current window up into three panes: - split vertically by typing in prefix % - next, split horizontally with prefix " You could just split panes into panes back and forth forever.

    If you get overwhelmed, you can kill your pane with prefix x

  4. Move between panes with prefix {arrow_key} Try navigating to different directories in each pane.

  5. Create a new window with prefix c. You'll notice that a new number has appeared on your tmux bar. You can switch to the corresponding window with prefix 0, prefix 1, etc Switch between your last two windows with prefix prefix Each window can be configured with its own panes.

  6. Now let's exit this session and create a new one. Type prefix d to detach from your current session.

  7. Create a brand new session with tmux new -s another_project

  8. Here's where you'd set up your panes / windows / and processes for another_project.

  9. Leave this session with prefix d

  10. See all of your available sessions with `tmux ls`
    
  11. Check out an existing session with `tmux a -t session_name` 
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment