Improvements to the list of plugins

This commit is contained in:
Bruno Sutic 2014-05-21 12:52:54 +02:00
parent 558814357d
commit 2e26affaa1
1 changed files with 18 additions and 10 deletions

View File

@ -33,11 +33,11 @@ however, you'll need just one.
We want the behavior of the plugin to trigger when a user hits `prefix + T`. We want the behavior of the plugin to trigger when a user hits `prefix + T`.
Key `T` is chosen: Key `T` is chosen because:
- it's kind of a mnemonic for `TPM` - it's "kind of" a mnemonic for `TPM`
- the key is not used by Tmux natively. Tmux man page, KEY BINDINGS section - the key is not used by Tmux natively. Tmux man page, KEY BINDINGS section
contains a list of all the bindings Tmux uses. We don't want to override a contains a list of all the bindings Tmux uses. We don't want to override any
Tmux default, and there's plenty of unused keys. Tmux default binding, and there's plenty of unused keys.
Open the plugin run file in your favorite text editor: Open the plugin run file in your favorite text editor:
@ -47,7 +47,7 @@ Open the plugin run file in your favorite text editor:
Put the following content in the file: Put the following content in the file:
#!/usr/env/bin bash #!/usr/bin/env bash
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
tmux bind-key T run-shell "$CURRENT_DIR/scripts/tmux_list_plugins.sh" tmux bind-key T run-shell "$CURRENT_DIR/scripts/tmux_list_plugins.sh"
@ -59,7 +59,7 @@ When pressed, `prefix + T` will now execute another shell script:
relative to the plugin run file. relative to the plugin run file.
### 4. create a script that does the job ### 4. listing plugins
Now that we have the binding, let's create a script that's invoked on Now that we have the binding, let's create a script that's invoked on
`prefix + T`. `prefix + T`.
@ -70,13 +70,15 @@ Now that we have the binding, let's create a script that's invoked on
And here's the script content: And here's the script content:
#!/usr/env/bin bash #!/usr/bin/env bash
# fetching the value of "tpm_plugins" option # fetching the value of "tpm_plugins" option
option_value=$(tmux show-option -gqv "@tpm_plugins") plugins_list=$(tmux show-option -gqv "@tpm_plugins")
# displaying variable content # displaying variable content, line by line
echo $option_value for plugin in $plugins_list; do
echo $plugin
done
### 5. try it out ### 5. try it out
@ -86,6 +88,9 @@ To try if this works, execute the plugin run file:
That should set up the key binding. Now hit `prefix + T` and see if it works. That should set up the key binding. Now hit `prefix + T` and see if it works.
If you get stuck you can download and check this tutorial
[plugin here](https://github.com/bruno-/tmux_example_plugin).
### 6. publish the plugin ### 6. publish the plugin
When everything works, push the plugin to an online git repository, preferably When everything works, push the plugin to an online git repository, preferably
@ -101,5 +106,8 @@ If the plugin is on Github, your users will be able to use the shorthand of
Hopefully, that was easy. As you can see, it's mostly shell scripting. Hopefully, that was easy. As you can see, it's mostly shell scripting.
You can also check source code of other plugins from the
[List of plugins](PLUGINS.md).
You can use other scripting languages (ruby, phyton etc), but plain old shell You can use other scripting languages (ruby, phyton etc), but plain old shell
is preferred because it will work almost anywhere. is preferred because it will work almost anywhere.