diff --git a/bindings/clean_plugins b/commands/tpm-clean similarity index 94% rename from bindings/clean_plugins rename to commands/tpm-clean index 9a0d5d7..37ebf9e 100755 --- a/bindings/clean_plugins +++ 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/bindings/install_plugins b/commands/tpm-install similarity index 94% rename from bindings/install_plugins rename to commands/tpm-install index 3ade3c4..37d798b 100755 --- a/bindings/install_plugins +++ 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/bindings/update_plugins b/commands/tpm-update similarity index 97% rename from bindings/update_plugins rename to commands/tpm-update index 28cc281..f29227b 100755 --- a/bindings/update_plugins +++ 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: 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..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" @@ -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 $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 # 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