From 0e2fab8c8fa2eb916020d025462681a49f921fa2 Mon Sep 17 00:00:00 2001 From: verschmelzen Date: Sat, 21 Aug 2021 10:42:06 +0300 Subject: [PATCH] Add commands and use them for bindings --- scripts/variables.sh | 4 ++++ tpm | 16 +++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/scripts/variables.sh b/scripts/variables.sh index 5601a86..75b02bd 100644 --- a/scripts/variables.sh +++ b/scripts/variables.sh @@ -7,6 +7,10 @@ default_update_key="U" clean_key_option="@tpm-clean" default_clean_key="M-u" +# TODO +# Since command-alias was not previosly used in tpm we need to make sure +# that the version here reflects the requirements for the command-alias to +# be present the required version for command-alias to work SUPPORTED_TMUX_VERSION="1.9" DEFAULT_TPM_ENV_VAR_NAME="TMUX_PLUGIN_MANAGER_PATH" diff --git a/tpm b/tpm index 7ad4b99..895eed5 100755 --- a/tpm +++ b/tpm @@ -53,18 +53,27 @@ source_plugins() { "$SCRIPTS_DIR/source_plugins.sh" >/dev/null 2>&1 } +# tpm-install - downloads TPM plugins and reloads TMUX environment +# tpm-update - updates a plugin (or all of them) and reloads TMUX environment +# tpm-clean - remove unused TPM plugins and reloads TMUX environment +set_tpm_commands() { + tmux set-option -ag command-alias "tpm-install=run-shell $BINDINGS_DIR/install_plugins" + tmux set-option -ag command-alias "tpm-update=run-shell $BINDINGS_DIR/update_plugins" + tmux set-option -ag command-alias "tpm-clean=run-shell $BINDINGS_DIR/clean_plugins" +} + # prefix + I - downloads TPM plugins and reloads TMUX environment # prefix + U - updates a plugin (or all of them) and reloads TMUX environment # 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 "$BINDINGS_DIR/install_plugins" + tmux bind-key "$install_key" tpm-install local update_key="$(get_tmux_option "$update_key_option" "$default_update_key")" - tmux bind-key "$update_key" run-shell "$BINDINGS_DIR/update_plugins" + tmux bind-key "$update_key" tpm-update local clean_key="$(get_tmux_option "$clean_key_option" "$default_clean_key")" - tmux bind-key "$clean_key" run-shell "$BINDINGS_DIR/clean_plugins" + tmux bind-key "$clean_key" tpm-clean } supported_tmux_version_ok() { @@ -74,6 +83,7 @@ supported_tmux_version_ok() { main() { if supported_tmux_version_ok; then set_tpm_path + set_tpm_commands set_tpm_key_bindings source_plugins fi