tpm/tpm

55 lines
1.8 KiB
Plaintext
Raw Normal View History

2014-05-18 22:35:55 +00:00
#!/usr/bin/env bash
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
SUPPORTED_TMUX_VERSION="1.9"
source "$CURRENT_DIR/scripts/variables.sh"
source "$CURRENT_DIR/scripts/helpers.sh"
2014-05-18 22:35:55 +00:00
# Ensures TMUX_PLUGIN_MANAGER_PATH global env variable is set.
# Default tpm path is "$HOME/.tmux/plugins/". That's where all the plugins are
# downloaded.
#
# Put this in `.tmux.conf` to override the default:
# `set-environment -g TMUX_PLUGIN_MANAGER_PATH "/some/other/path/"`
set_tpm_path() {
2014-05-24 21:15:13 +00:00
$CURRENT_DIR/scripts/set_tpm_path.sh >/dev/null 2>&1
2014-05-18 22:35:55 +00:00
}
2015-07-06 23:49:33 +00:00
# 1. Fetches plugin names from `@plugin` variables
2014-05-18 22:35:55 +00:00
# 2. Creates full plugin path
# 3. Sources all *.tmux files from each of the plugin directories
2014-05-24 21:15:13 +00:00
# - no errors raised if directory does not exist
2014-05-18 22:35:55 +00:00
# Files are sourced as tmux config files, not as shell scripts!
source_plugins() {
2014-05-24 21:15:13 +00:00
$CURRENT_DIR/scripts/source_plugins.sh >/dev/null 2>&1
2014-05-18 22:35:55 +00:00
}
# prefix + I - downloads TPM plugins and reloads TMUX environment
# prefix + U - updates a plugin (or all of them) and reloads TMUX environment
2015-06-02 19:36:35 +00:00
# prefix + alt + u - remove unused TPM plugins and reloads TMUX environment
set_tpm_key_bindings() {
local install_key=$(get_tmux_option "$install_key_option" "$default_install_key")
tmux bind-key "$install_key" run-shell "$CURRENT_DIR/scripts/install_plugins.sh >/dev/null 2>&1"
local update_key=$(get_tmux_option "$update_key_option" "$default_update_key")
tmux bind-key "$update_key" run-shell "$CURRENT_DIR/scripts/update_plugin_prompt.sh"
2015-05-27 03:46:15 +00:00
local clean_key=$(get_tmux_option "$clean_key_option" "$default_clean_key")
tmux bind-key "$clean_key" run-shell "$CURRENT_DIR/scripts/clean_plugins.sh"
2014-05-18 22:35:55 +00:00
}
supported_tmux_version_ok() {
$CURRENT_DIR/scripts/check_tmux_version.sh "$SUPPORTED_TMUX_VERSION"
}
2014-05-18 22:35:55 +00:00
main() {
if supported_tmux_version_ok; then
set_tpm_path
set_tpm_key_bindings
source_plugins
fi
2014-05-18 22:35:55 +00:00
}
main