Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- A regular plugin only needs to have execution priviledges.
- For instance, lets look at this 'hello world' plugin:
- ```bash
- #!/bin/bash
- echo "hello world!"
- ```
- 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:
- ```bash
- #!/bin/bash
- PLUGIN_DIR=$(tmux show-option -gqv "@status_variables_dir")
- source "$PLUGIN_DIR/utils/sdk.sh"
- on_cache_miss() {
- echo "hello world!"
- sleep 1
- }
- echo "$(get_cached_value on_cache_miss)"
- ```
- `on_cache_miss` will run only when `status-interval` seconds have passed.
- This is important because tmux might refreshe the status line when redrawing the pane.
- Every time you press <Enter> or create a new pane, the status line is refreshed which causes many script calls.
- Now all that's left is to run it:
- 1. Dump the content of the script to the `scripts_directory`, and name it `hello_world.tmux`
- 2. Add `set -g status-left "#{hello_world}"` to your `tmux.conf` and your good to go!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement