Wrangle your terminal with tmux

27 minutes

Learn to manage your terminal sessions and work more effectively from the command line using tmux. If you use the command line at all, tmux can make your life easier.

tmux bills itself as a terminal multiplexer. It allows you to wrangle multiple terminal sessions from one window. Instead of keeping track of many terminal windows yourself, you can use tmux to create, organize, and navigate between them. Even more importantly, tmux lets you detach from and re-attach sessions, so that you can leave your terminal sessions running in the background and resume them later. This is especially useful if you're working on a remote server: you can set up a persistent session that will continue running when you close your laptop. You can even share a tmux session to facilitate pair programming.

pro-course-rss-logo

PRO RSS Feed

Organize your terminal using tmux panes

Create collections of panes using tmux windows

Reuse terminal workspaces using tmux sessions

Manage terminal workspaces using session naming

Zoom and resize to view a particular pane within tmux

Customize tmux with tmux.conf

Copy and paste text from a tmux session

Enable mouse mode in tmux

Automate your workflow using tmux scripts

Share a tmux session for pair programming with ssh

Handle history in tmux sessions

otherjs tutorial about Organize your terminal using tmux panes

Organize your terminal using tmux panes

2:14 otherjs

Learn to organize your workspace using tmux. We'll create a new tmux session and learn how to create and navigate panes within a tmux window.

We'll cover:

  • How to create new panes via vertical splits with C-b %
  • How to create new panes via horizontal splits with C-b "
  • Navigating between panes with C-b and arrow keys
  • Closing panes with exit or Ctrl-d
  • Viewing available commands with C-b ?
otherjs tutorial about Create collections of panes using tmux windows

Create collections of panes using tmux windows

1:19 otherjs

In tmux, a window is a collection of panes. Creating multiple windows is a great way to organize your workspace. In this lesson, we'll cover:

  • How to create a new window within a tmux session, using C-b c
  • Navigating between windows with C-b n and C-b p
otherjs tutorial about Reuse terminal workspaces using tmux sessions

Reuse terminal workspaces using tmux sessions

1:54 otherjs

In this lesson, we'll learn how to detach from a running tmux session and leave it running in the background. Then, we can re-attach to it later.

We'll cover:
- How to exit a session by killing all active panes
- Detaching explicitly with C-b d
- Detaching a specific session with C-b D
- Viewing all running tmux sessions using tmux ls
- Reattaching with tmux attach -t

otherjs tutorial about Manage terminal workspaces using session naming

Manage terminal workspaces using session naming

1:33 otherjs

It's a lot easier to manage your tmux session when they have sensible names. We'll cover:

  • How to create a new, named tmux session with tmux new -s
  • Rename an existing tmux session using tmux rename-session -t
  • Renaming sessions with C-b $
  • Listing sessions with C-b s
otherjs tutorial about Zoom and resize to view a particular pane within tmux

Zoom and resize to view a particular pane within tmux

1:39 otherjs

Sometimes you'll want to zoom in on a specific pane within a tmux window. We'll learn to use C-b z to temporarily zoom in on one pane, as well as how to resize your panes with C-b -L, -R, -U, and -D.

otherjs tutorial about Customize tmux with tmux.conf

Customize tmux with tmux.conf

3:52 otherjs

You can modify tmux's behavior with your tmux configuration file, .tmux.conf. You can use your tmux config to change color schemes, set custom keybindings, set defaults, modify the status bar, and more. In this lesson, we'll change some of the default color options as well as modify the prefix key.

otherjs tutorial about Copy and paste text from a tmux session

Copy and paste text from a tmux session

3:13 otherjs

One non-obvious, but extremely useful, feature in tmux is copy-pasting text between panes. This also allows you to scroll back in a tmux sessoin. We'll cover how to use copy and paste in tmux using C-b [ and C-b ], for both emacs- and vim-style keybindings.

otherjs tutorial about Enable mouse mode in tmux

Enable mouse mode in tmux

2:22 otherjs

We'll learn how to use mouse mode in tmux, including enable mouse control for resizing, scrolling and selecting panes. We'll also set keybindings in our tmux configuration to control mouse mode.

otherjs tutorial about Automate your workflow using tmux scripts

Automate your workflow using tmux scripts

3:53 otherjs

Do you have a standard workflow that involves setting up a specific tmux layout, or running certain commands? By writing tmux scripts, you can automate your tedious daily setup, while simultaneously documenting it for yourself. We'll cover the tmux command equivalents of common key bindings and write some simple, useful scripts.

otherjs tutorial about Share a tmux session for pair programming with ssh

Share a tmux session for pair programming with ssh

1:52 otherjs

By using ssh, you can share a tmux session, making pair programming much easier. We'll learn how to share a tmux session with another user.

otherjs tutorial about Handle history in tmux sessions

Handle history in tmux sessions

3:11 otherjs

In this lesson, we'll look at how to manage your history between tmux sessions, and ensure that your setup preserves your bash history between multiple windows. By adding a special PROMPT_COMMAND to your .bashrc, you can update and reload your history after every command, regardless of if you're in a different session, window, or tab.

Presented by:

Bonnie Eisenman

Working on Scala and distributed systems stuff at Twitter. Author of Learning React Native. Buy my book: http://bit.ly/lrnamaff

HEY, QUICK QUESTION!
Joel's Head
Why are we asking?