How to use tmux package manager (TPM)?

Quick Answer

Tmux Plugin Manager (TPM) is a tool that simplifies the installation and management of tmux plugins. Install it with git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm, add plugins to your .tmux.conf, then install with PREFIX + I.

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

Detailed Explanation

The Tmux Plugin Manager (TPM) is a package manager specifically designed for tmux. It allows you to easily install, update, and remove plugins that extend tmux's functionality. These plugins can add features like saving and restoring sessions, CPU usage indicators, battery status, and more.

Installing TPM:

  1. Clone the TPM repository to your tmux plugins directory:
    git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
  2. Add TPM to your ~/.tmux.conf:
    # List of plugins
    set -g @plugin 'tmux-plugins/tpm'
    
    # Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
    run '~/.tmux/plugins/tpm/tpm'
  3. Reload your tmux configuration:
    tmux source-file ~/.tmux.conf

Adding plugins:

To add a plugin, include it in your .tmux.conf file:

# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-continuum'

Managing plugins with TPM:

  • PREFIX + I - Install new plugins
  • PREFIX + U - Update plugins
  • PREFIX + alt+u - Remove/uninstall plugins not in the list

Popular tmux plugins:

tmux-sensibleBasic tmux settings everyone can agree on
tmux-resurrectSave and restore tmux sessions
tmux-continuumContinuous saving and automatic restore
tmux-copycatEnhanced search and copy capabilities

Troubleshooting

If plugins aren't installing correctly, check that:

  1. TPM is properly initialized at the bottom of your config
  2. You have Git installed on your system
  3. The plugin repository URLs are correct
  4. You've sourced your config after changes

Pro Tip

Most plugins allow custom configuration. Always check the plugin's README for available options. Example:

# Configure plugin options
set -g @resurrect-capture-pane-contents 'on'
set -g @continuum-restore 'on'