tmux is awsome, but creating scripts for the status line is a lot of work. I’ve looked into different scripts at the tmux-plugins repo and saw a recurring pattern. Or dare I say, a lot of copy-n-pasting of the same code from one plugin to another. Many of them lay the same groundwork:
- Add utils function to get or set tmux options
 - Add code that transforms the status line and calls the scripts
 - Add a caching layer to make sure no redudant calls are made
 
I’ve taken the liberty to create a plugin, tmux-status-variables, that helps creating and using status line scripts extremely easy.
A regular plugin only needs to have execution priviledges.
 For instance, lets look at this hello world plugin:
  | 
If hello world takes a lot of time, we might want to cache the result.
 Results are cached for status-interval seoconds. lets look at the following plugin:
#!/bin/bash  | 
on_cache_miss will run only when status-interval seconds have passed.
 This is important because tmux might refreshes the status line when redrawing the pane.
 Every time you press or create a new pane, the status line is refreshed which causes many script calls.
Now all that’s left is to run it:
- Dump the content of the script to the 
scripts_directory, and name ithello.tmux - Add 
set -g status-left "#{hello}"to yourtmux.confand your good to go!