0

I'm wanting to build a TPM based plugin but the example provided is extremely minimal, doesn't explain how to do things (like creating commmands that can be used in the tmux status bar, or how to have args passed to the plugin for example).

Is there a super annotated plugin I can look at to get a better idea of how it works? or some better information about this?

1
  • @meuh of course you can add new ones, how else do they add status bar commands to display battery level, internet status, cpu usage, etc? Commented Aug 11, 2018 at 16:32

1 Answer 1

4

A tmux plugin is just a shell script in a conventional place (~/.tmux/plugins/) that the plugin manager will look for and run using the built-in tmux run-shell command. It is just packaging for cleanliness. The shell script implements everything else with the standard built-in tmux commands. You cannot add any new ones. See man tmux for all the commands.

If you look at the cpu plugin, it allows you to have new status line options like #{cpu_percentage}. To do this it uses

tmux show-option -gqv status-right

to find your wanted configuration string, and replaces matching options by a call to one of the other shell scripts provided by the plugin, namely in this case

#(~/.tmux/plugins/tmux-cpu/scripts/cpu_percentage.sh)

The form #() is standard built-in tmux syntax to run a shell command from the value of status-right and other variables. See the man page under section FORMATS.

The updated status-right string is given back to tmux with tmux set-option -qg status-right.

5
  • Awesome! that's what I was looking for, one thing though, How do I pass stuff like, pane_id or pane_current_path to the scripts or figure out which pane was active when a command was run? Commented Aug 11, 2018 at 17:44
  • 1
    I'm not a tmux expert, and there are lots of tmux commands I don't know, so you may need to post more specific questions with exact details of what you would like to do, but for example, tmux display -p '#{pane_index}' from a shell script will print the current pane number (0 or 1 etc). Commented Aug 11, 2018 at 18:18
  • Thanks @meuh!, that's what I was looking for, I think that's what I need to get what I want working, you've been a super big help! Commented Aug 11, 2018 at 18:35
  • I get it, I GET IT, I get how they addd stuff like #{cpu_icon}, it's super dirty, but I get it!, #{cpu_icon} doesn't get replaced in tmux, instead the script gets executed in shell script and will replace #{cpu_icon} with the output of cpu_icon.sh using shell style ${variable//pattern/replacement}. Commented Aug 11, 2018 at 20:12
  • 1
    Apologies, it doesn't replace with the output, rather it replaces it #{cpu} with #(~/path/to/cpu.sh) Commented Aug 11, 2018 at 20:37

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.