Mastodon hachyterm.io

Now that we’ve installed tmux, the terminal multiplexer, how do we use it?

  1. Start your project from your shell

In the terminal, I navigate to the directory containing my project.

  1. Start a new tmux session
tmux new -t <project-name>

I usually name the tmux session after the project directory to avoid confusion.

For example, if the project folder is called flask-react-auth, I create a new session with: tmux new -t flask-react-auth.

  1. Use tmux with (Neo)Vim

The tmux session looks almost the same as the standard terminal. I now open a few tmux panes. Most of the time, the main “window” contains my Vim session, and a secondary smaller pane is for running shell processes.

You can open new panes with <prefix>% and <prefix>=.
(The standard prefix key mapping is CTRL+B.)

  1. Detach from the session

If you’re finished with your work, you can detach from the tmux session.

tmux detach

Or run <prefix>d. (The standard prefix key mapping is CTRL+B.)

If you use tmux-continuum, your session will be saved automatically.

You can easily jump back into the session with tmux attach -t <project-name>.

See a list of current tmux servers with tmux list.

  1. Some other tricks

You can open a new tmux window with <prefix>c.

You can see a list of all panes and windows with <prefix>w.

Further Reading