Home Terminal Tuts Maximize functionality with these tmux plugins & extensions

Maximize functionality with these tmux plugins & extensions

Tmux is a powerful tool that can help you be more productive. With plugins and extensions, you can customize Tmux to fit your needs and make it even more powerful.

by Abraham
tmux plugins & extensions

As a developer, you might find yourself spending a considerable amount of time working in the terminal. And if you’re like most developers, you probably use Tmux to manage your terminal windows. Tmux is a potent tool that allows you to split your terminal into multiple panes and windows, making it easy to multitask and work more efficiently. But did you know you can extend Tmux’s functionality using plugins and extensions? In this article, we’ll explore some Tmux plugins and extensions that can help you take your productivity to the next level.

What are tmux plugins and extensions?

Tmux plugins and extensions are scripts and tools that add extra functionality to Tmux. The Tmux community typically develops and maintains them, and they can be easily installed using package managers like Tmux Plugin Manager (TPM).

Some plugins and extensions add new features to Tmux, such as a status bar with additional information or copying and pasting between Tmux panes. Others make it easier to customize Tmux’s behavior by allowing you to define custom key bindings or themes.

Installing tmux

Before we dive into Tmux plugins and extensions, it’s essential to understand how to install Tmux on your system. Tmux is available for most Linux distributions, as well as for macOS and Windows. On most Linux distributions, you can install Tmux using your package manager. For example, on Ubuntu or Debian, you can install Tmux using the following command:

sudo apt-get install tmux
install tmux

Install tmux

Once you’ve installed Tmux, you can start using it by opening a terminal window and typing tmux.

Getting started with Tmux

When you first start Tmux, you’ll be presented with a new terminal window that looks similar to your regular terminal window but with some added features. One of the most valuable features of Tmux is the ability to split your terminal window into multiple panes, allowing you to run multiple commands simultaneously.

To split your terminal window in Tmux, you can use the prefix % and prefix “ key combinations, where the prefix key is ctrl-b by default. The prefix % combination splits the current pane vertically, while the prefix “ combination splits the current pane horizontally. You can switch between panes using the prefix arrow keys.

Tmux Plugin Manager (TPM)

Before we dive into some of the best Tmux plugins and extensions, Tmux Plugin Manager (TPM) is worth mentioning. TPM is a popular package manager for Tmux plugins and extensions, making installing and managing them easy. It makes it easy to install, update, and remove plugins and handles dependencies automatically.

To install TPM, you’ll first need to clone the TPM repository:

git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
clone tmux plugin manager

Clone Tmux Plugin Manager

Once you’ve cloned the repository, you can add the following line to your .tmux.conf file to initialize TPM:

# Initialize TPM (Tmux Plugin Manager)

set -g @plugin 'tmux-plugins/tpm'

run '~/.tmux/plugins/tpm/tpm'
initialize tpm

Initialize TPM

Then reload your Tmux configuration by running:

tmux source-file ~/.tmux.conf
reload tmux config file

Reload the Tmux config file

To install a plugin using TPM, add the following line to your .tmux.conf file:

set -g @plugin 'PLUGIN_NAME'

Replace PLUGIN_NAME with the name of the plugin you want to install. For example, to install Tmux Resurrect using TPM, add the following line:

set -g @plugin 'tmux-plugins/tmux-resurrect'
resurrect plugin

Resurrect plugin

Then press prefix + I (capital i) to install the plugin.

To update a TPM plugin, press prefix + U (capital u).

To remove a plugin using TPM, remove the corresponding set -g @plugin line from your .tmux.conf file, and then press prefix + alt + u to remove the plugin.

With TPM installed and initialized, you can install Tmux plugins and extensions.

Tmux plugins and extensions

Tmux plugins are additional scripts and utilities that can be installed to extend the functionality of Tmux. Many plugins are available for Tmux, which can significantly enhance your workflow and productivity. Here are some of the best Tmux plugins and extensions that can help you work more efficiently:

Tmux Resurrect

Tmux Resurrect is a plugin allowing you to save and restore your Tmux sessions, including all the windows, panes, and layouts. It also saves the state of individual processes running in each pane, so you can restore them to their previous state when you reload the session.

With Tmux Resurrect, you can easily pick up where you left off, even after restarting your computer.

To install Tmux Resurrect using TPM, add the following line to your .tmux.conf file:

# Tmux Resurrect

set -g @plugin 'tmux-plugins/tmux-resurrect'
install resurrect plugin

Install Resurrect plugin

Once you’ve added the line, reload your Tmux configuration by running the following:

tmux source-file ~/.tmux.conf
reload tmux config file

Reload the Tmux config file

Then press prefix + I to install the plugin.

To save your Tmux session, use the following key binding:

prefix + Ctrl-s

To restore your Tmux session, use the following key binding:

prefix + Ctrl-r

Tmux Continuum

Tmux Continuum is a plugin that automatically saves and restores your Tmux sessions at regular intervals, so you don’t have to remember to do it manually. It also provides a status line indicator to show when the last save occurred. This ensures you never lose your work, even if your computer crashes or you accidentally close your terminal.

To install Tmux Continuum using TPM, add the following line to your .tmux.conf file:

# Tmux Continuum

set -g @plugin 'tmux-plugins/tmux-continuum'
install continuum plugin

Install Continuum plugin

Once you’ve added the line, reload your Tmux configuration by running the following:

tmux source-file ~/.tmux.conf
reload tmux config file

Reload the Tmux config file

Then press prefix + I to install the plugin.

Tmux Continuum is enabled by default, but you can customize its behavior by adding the following lines to your .tmux.conf file:

# Tmux Continuum

set -g @continuum-restore 'on'

set -g @continuum-save-interval '15'

set -g @continuum-save-uptime 'on'
customize continuum plugin

Customize continuum plugin

The @continuum-restore option controls whether Tmux Continuum restores the last saved session automatically when you start Tmux. The @continuum-save-interval option sets the interval between saves in minutes. To avoid overwriting previous saves, the @continuum-save-uptime option controls whether Tmux Continuum includes the system uptime in the save file name.

Tmux Copycat

Tmux Copycat is a plugin that enhances Tmux’s copy mode by allowing you to search and highlight text within Tmux panes. With Tmux Copycat, you can quickly jump to the next occurrence of a specific string or pattern, making finding what you’re looking for within a large log file or output easier.

To install Tmux Copycat using TPM, add the following line to your .tmux.conf file:

set -g @plugin 'tmux-plugins/tmux-copycat'
copycat plugin

Copycat plugin

Then press prefix + I to install the plugin.

To use Tmux Copycat, enter copy mode by pressing prefix + [, then press Ctrl-b followed by / to enter search mode. Type your search string or pattern and press Enter to highlight the next occurrence. Press n to jump to the next occurrence or N to jump to the previous one.

Tmux Copycat also provides several other useful commands, such as prefix + / to search for the current selection, prefix + Shift-s to search for the currently running command and prefix + Shift-f to search for a filename within the current pane.

Below are some essential key bindings to use while using this plugin:

  • Ctrl-u: Search for the current word under the cursor.
  • Ctrl-d: Search backward for the current word under the cursor.
  • Ctrl-f: Search forwards for a user-defined pattern.
  • Ctrl-g: Cancel search mode.
  • Enter: Copy the highlighted text.

Tmux Copycat can save time and streamline your workflow by quickly finding the information you need within your Tmux panes.

Tmux Yank

Tmux Yank is a plugin that allows you to copy and paste between Tmux panes and the system clipboard. With Tmux Yank, you can quickly transfer text between different applications and Tmux sessions.

To install Tmux Yank using TPM, add the following line to your .tmux.conf file:

# Tmux Yank

set -g @plugin 'tmux-plugins/tmux-yank'
install tmux yank plugin

Install the Tmux Yank plugin

Once you’ve added the line, reload your Tmux configuration by running the following:

tmux source-file ~/.tmux.conf
reload tmux config file

Reload the Tmux config file

To copy text to the system clipboard from a Tmux pane, use the following key binding:

prefix + y

To paste text from the system clipboard into a Tmux pane, use the following key binding:

prefix + Y

Tmux Themepack

Tmux Themepack is a collection of themes for Tmux that you can use to customize its appearance. With Tmux Themepack, you can choose from various themes that suit your personal preferences and style.

To install Tmux Themepack using TPM, add the following line to your .tmux.conf file:

# Tmux Themepack

set -g @plugin 'jimeh/tmux-themepack'
install themepack plugin

Install the theme pack plugin

Once you’ve added the line, reload your Tmux configuration by running the following:

tmux source-file ~/.tmux.conf
reload tmux config file

Reload the Tmux config file

To activate a theme, add the following line to your .tmux.conf file:

# Tmux Themepack Theme

set -g @themepack 'THEME_NAME'

Remember to replace the THEME_NAME with the theme name you want to use.

Additional Tips & Tricks

There are a few additional tips and tricks worth mentioning regarding Tmux plugins and extensions:

Tmuxinator

Tmuxinator is a tool for managing Tmux sessions using YAML configuration files. It allows you to define complex Tmux sessions with multiple windows and panes and start them with a single command.

To install Tmuxinator, run the following command:

gem install tmuxinator
install tmuxinator

Install tmuxinator

Once you’ve installed Tmuxinator, create a new project by running the following:

tmuxinator new PROJECT_NAME
create new project

Create new project

This will create a new YAML configuration file for your project in the ~/.tmuxinator/ directory.

Edit the configuration file to define your Tmux session, and then start it by running:

tmuxinator start PROJECT_NAME
tmuxinator start project

Tmuxinator start project

Tmuxinator also provides many useful commands for managing your sessions, such as tmuxinator list to list your projects, tmuxinator edit PROJECT_NAME to edit a project’s configuration file, and tmuxinator delete PROJECT_NAME to delete a project.

Tmuxp

Tmuxp is another tool for managing Tmux sessions using YAML configuration files. It allows you to define and manage Tmux sessions, windows, and panes with a simple and intuitive syntax.

To install Tmuxp, run the following command:

pip install tmuxp
install tmuxp

Install tmuxp

Once you’ve installed Tmuxp, create a new YAML configuration file for your Tmux session. Here’s an example configuration file:

session_name: mysession 
windows: 
- window_name: editor 
layout: main-vertical 
options: 
main-pane-height: 60% 
panes: 
- vim 
- top 
- window_name: console 
panes: 
- bash 
- bash 
- bash
yaml config file

Yaml config file

This configuration file defines a Tmux session with two windows: “editor” and “console.” The “editor” window has two panes, one running Vim and the other running the top command, and uses a main-vertical layout with the main pane taking up 60% of the screen. The “console” window has three panes, each running a Bash shell.

To start the Tmux session using the configuration file, run the following command:

tmuxp load config.yaml

This will create the Tmux session with the specified windows and panes.

Tmuxp also provides some other useful commands, such as tmuxp freeze SESSION_NAME to save the current state of a Tmux session to a YAML file, and tmuxp load CONFIG_FILE.yaml to load a Tmux session from a YAML file.

Conclusion

Tmux plugins and extensions can significantly improve your workflow and productivity in the command line. Utilizing these tools allows you to customize Tmux to fit your specific needs and preferences, making it an even more powerful tool for managing your terminal sessions. From simple plugins that add new features to more advanced extensions that automate tasks, many options are available to help you get the most out of Tmux. We hope this article has provided valuable tips and tricks for using Tmux plugins and extensions and that you are now equipped to take your Tmux experience to the next level.

You may also like

Leave a Comment

fl_logo_v3_footer

ENHANCE YOUR LINUX EXPERIENCE.



FOSS Linux is a leading resource for Linux enthusiasts and professionals alike. With a focus on providing the best Linux tutorials, open-source apps, news, and reviews written by team of expert authors. FOSS Linux is the go-to source for all things Linux.

Whether you’re a beginner or an experienced user, FOSS Linux has something for everyone.

Follow Us

Subscribe

©2016-2023 FOSS LINUX

A PART OF VIBRANT LEAF MEDIA COMPANY.

ALL RIGHTS RESERVED.

“Linux” is the registered trademark by Linus Torvalds in the U.S. and other countries.