From 0e2fab8c8fa2eb916020d025462681a49f921fa2 Mon Sep 17 00:00:00 2001 From: verschmelzen Date: Sat, 21 Aug 2021 10:42:06 +0300 Subject: [PATCH 1/3] 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 From d2687118663853286a7c395c69923608b937782f Mon Sep 17 00:00:00 2001 From: verschmelzen Date: Sun, 22 Aug 2021 14:22:53 +0300 Subject: [PATCH 2/3] Rename binding scripts to command --- bindings/clean_plugins => commands/tpm-clean | 0 bindings/install_plugins => commands/tpm-install | 0 bindings/update_plugins => commands/tpm-update | 0 tpm | 8 ++++---- 4 files changed, 4 insertions(+), 4 deletions(-) rename bindings/clean_plugins => commands/tpm-clean (100%) rename bindings/install_plugins => commands/tpm-install (100%) rename bindings/update_plugins => commands/tpm-update (100%) diff --git a/bindings/clean_plugins b/commands/tpm-clean similarity index 100% rename from bindings/clean_plugins rename to commands/tpm-clean diff --git a/bindings/install_plugins b/commands/tpm-install similarity index 100% rename from bindings/install_plugins rename to commands/tpm-install diff --git a/bindings/update_plugins b/commands/tpm-update similarity index 100% rename from bindings/update_plugins rename to commands/tpm-update diff --git a/tpm b/tpm index 895eed5..ce72cbd 100755 --- a/tpm +++ b/tpm @@ -1,7 +1,7 @@ #!/usr/bin/env bash CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -BINDINGS_DIR="$CURRENT_DIR/bindings" +COMMANDS_DIR="$CURRENT_DIR/commands" SCRIPTS_DIR="$CURRENT_DIR/scripts" source "$SCRIPTS_DIR/variables.sh" @@ -57,9 +57,9 @@ source_plugins() { # 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" + tmux set-option -ag command-alias "tpm-install=run-shell $COMMANDS_DIR/tpm-install" + tmux set-option -ag command-alias "tpm-update=run-shell $COMMANDS_DIR/tpm-update" + tmux set-option -ag command-alias "tpm-clean=run-shell $COMMANDS_DIR/tpm-clean" } # prefix + I - downloads TPM plugins and reloads TMUX environment From 669614473c443170a19f9b492b5ea7b0d22d55c3 Mon Sep 17 00:00:00 2001 From: verschmelzen Date: Sun, 22 Aug 2021 14:31:30 +0300 Subject: [PATCH 3/3] Rename mentions of bindings in command scripts --- commands/tpm-clean | 2 +- commands/tpm-install | 2 +- commands/tpm-update | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/commands/tpm-clean b/commands/tpm-clean index 9a0d5d7..37ebf9e 100755 --- a/commands/tpm-clean +++ b/commands/tpm-clean @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# Tmux key-binding script. +# Tmux command script. # Scripts intended to be used via the command line are in `bin/` directory. CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" diff --git a/commands/tpm-install b/commands/tpm-install index 3ade3c4..37d798b 100755 --- a/commands/tpm-install +++ b/commands/tpm-install @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# Tmux key-binding script. +# Tmux command script. # Scripts intended to be used via the command line are in `bin/` directory. CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" diff --git a/commands/tpm-update b/commands/tpm-update index 28cc281..f29227b 100755 --- a/commands/tpm-update +++ b/commands/tpm-update @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# Tmux key-binding script. +# Tmux command script. # Scripts intended to be used via the command line are in `bin/` directory. # This script: