summaryrefslogtreecommitdiff
path: root/tmux/.tmux/plugins/tpm/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'tmux/.tmux/plugins/tpm/scripts')
-rwxr-xr-xtmux/.tmux/plugins/tpm/scripts/check_tmux_version.sh78
-rwxr-xr-xtmux/.tmux/plugins/tpm/scripts/clean_plugins.sh41
-rw-r--r--tmux/.tmux/plugins/tpm/scripts/helpers/plugin_functions.sh104
-rw-r--r--tmux/.tmux/plugins/tpm/scripts/helpers/shell_echo_functions.sh7
-rw-r--r--tmux/.tmux/plugins/tpm/scripts/helpers/tmux_echo_functions.sh28
-rw-r--r--tmux/.tmux/plugins/tpm/scripts/helpers/tmux_utils.sh6
-rw-r--r--tmux/.tmux/plugins/tpm/scripts/helpers/utility.sh17
-rwxr-xr-xtmux/.tmux/plugins/tpm/scripts/install_plugins.sh75
-rwxr-xr-xtmux/.tmux/plugins/tpm/scripts/source_plugins.sh42
-rwxr-xr-xtmux/.tmux/plugins/tpm/scripts/update_plugin.sh78
-rwxr-xr-xtmux/.tmux/plugins/tpm/scripts/update_plugin_prompt_handler.sh18
-rw-r--r--tmux/.tmux/plugins/tpm/scripts/variables.sh13
12 files changed, 0 insertions, 507 deletions
diff --git a/tmux/.tmux/plugins/tpm/scripts/check_tmux_version.sh b/tmux/.tmux/plugins/tpm/scripts/check_tmux_version.sh
deleted file mode 100755
index b0aedec..0000000
--- a/tmux/.tmux/plugins/tpm/scripts/check_tmux_version.sh
+++ /dev/null
@@ -1,78 +0,0 @@
-#!/usr/bin/env bash
-
-VERSION="$1"
-UNSUPPORTED_MSG="$2"
-
-get_tmux_option() {
- local option=$1
- local default_value=$2
- local option_value=$(tmux show-option -gqv "$option")
- if [ -z "$option_value" ]; then
- echo "$default_value"
- else
- echo "$option_value"
- fi
-}
-
-# Ensures a message is displayed for 5 seconds in tmux prompt.
-# Does not override the 'display-time' tmux option.
-display_message() {
- local message="$1"
-
- # display_duration defaults to 5 seconds, if not passed as an argument
- if [ "$#" -eq 2 ]; then
- local display_duration="$2"
- else
- local display_duration="5000"
- fi
-
- # saves user-set 'display-time' option
- local saved_display_time=$(get_tmux_option "display-time" "750")
-
- # sets message display time to 5 seconds
- tmux set-option -gq display-time "$display_duration"
-
- # displays message
- tmux display-message "$message"
-
- # restores original 'display-time' value
- tmux set-option -gq display-time "$saved_display_time"
-}
-
-# this is used to get "clean" integer version number. Examples:
-# `tmux 1.9` => `19`
-# `1.9a` => `19`
-get_digits_from_string() {
- local string="$1"
- local only_digits="$(echo "$string" | tr -dC '[:digit:]')"
- echo "$only_digits"
-}
-
-tmux_version_int() {
- local tmux_version_string=$(tmux -V)
- echo "$(get_digits_from_string "$tmux_version_string")"
-}
-
-unsupported_version_message() {
- if [ -n "$UNSUPPORTED_MSG" ]; then
- echo "$UNSUPPORTED_MSG"
- else
- echo "Error, Tmux version unsupported! Please install Tmux version $VERSION or greater!"
- fi
-}
-
-exit_if_unsupported_version() {
- local current_version="$1"
- local supported_version="$2"
- if [ "$current_version" -lt "$supported_version" ]; then
- display_message "$(unsupported_version_message)"
- exit 1
- fi
-}
-
-main() {
- local supported_version_int="$(get_digits_from_string "$VERSION")"
- local current_version_int="$(tmux_version_int)"
- exit_if_unsupported_version "$current_version_int" "$supported_version_int"
-}
-main
diff --git a/tmux/.tmux/plugins/tpm/scripts/clean_plugins.sh b/tmux/.tmux/plugins/tpm/scripts/clean_plugins.sh
deleted file mode 100755
index a025524..0000000
--- a/tmux/.tmux/plugins/tpm/scripts/clean_plugins.sh
+++ /dev/null
@@ -1,41 +0,0 @@
-#!/usr/bin/env bash
-
-CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
-HELPERS_DIR="$CURRENT_DIR/helpers"
-
-source "$HELPERS_DIR/plugin_functions.sh"
-source "$HELPERS_DIR/utility.sh"
-
-if [ "$1" == "--tmux-echo" ]; then # tmux-specific echo functions
- source "$HELPERS_DIR/tmux_echo_functions.sh"
-else # shell output functions
- source "$HELPERS_DIR/shell_echo_functions.sh"
-fi
-
-clean_plugins() {
- local plugins plugin plugin_directory
- plugins="$(tpm_plugins_list_helper)"
-
- for plugin_directory in "$(tpm_path)"/*; do
- [ -d "${plugin_directory}" ] || continue
- plugin="$(plugin_name_helper "${plugin_directory}")"
- case "${plugins}" in
- *"${plugin}"*) : ;;
- *)
- [ "${plugin}" = "tpm" ] && continue
- echo_ok "Removing \"$plugin\""
- rm -rf "${plugin_directory}" >/dev/null 2>&1
- [ -d "${plugin_directory}" ] &&
- echo_err " \"$plugin\" clean fail" ||
- echo_ok " \"$plugin\" clean success"
- ;;
- esac
- done
-}
-
-main() {
- ensure_tpm_path_exists
- clean_plugins
- exit_value_helper
-}
-main
diff --git a/tmux/.tmux/plugins/tpm/scripts/helpers/plugin_functions.sh b/tmux/.tmux/plugins/tpm/scripts/helpers/plugin_functions.sh
deleted file mode 100644
index f33d215..0000000
--- a/tmux/.tmux/plugins/tpm/scripts/helpers/plugin_functions.sh
+++ /dev/null
@@ -1,104 +0,0 @@
-# using @tpm_plugins is now deprecated in favor of using @plugin syntax
-tpm_plugins_variable_name="@tpm_plugins"
-
-# manually expanding tilde char or `$HOME` variable.
-_manual_expansion() {
- local path="$1"
- local expanded_tilde="${path/#\~/$HOME}"
- echo "${expanded_tilde/#\$HOME/$HOME}"
-}
-
-_tpm_path() {
- local string_path="$(tmux start-server\; show-environment -g TMUX_PLUGIN_MANAGER_PATH | cut -f2 -d=)/"
- _manual_expansion "$string_path"
-}
-
-_CACHED_TPM_PATH="$(_tpm_path)"
-
-# Get the absolute path to the users configuration file of TMux.
-# This includes a prioritized search on different locations.
-#
-_get_user_tmux_conf() {
- # Define the different possible locations.
- xdg_location="${XDG_CONFIG_HOME:-$HOME/.config}/tmux/tmux.conf"
- default_location="$HOME/.tmux.conf"
-
- # Search for the correct configuration file by priority.
- if [ -f "$xdg_location" ]; then
- echo "$xdg_location"
-
- else
- echo "$default_location"
- fi
-}
-
-_tmux_conf_contents() {
- user_config=$(_get_user_tmux_conf)
- cat /etc/tmux.conf "$user_config" 2>/dev/null
- if [ "$1" == "full" ]; then # also output content from sourced files
- local file
- for file in $(_sourced_files); do
- cat $(_manual_expansion "$file") 2>/dev/null
- done
- fi
-}
-
-# return files sourced from tmux config files
-_sourced_files() {
- _tmux_conf_contents |
- sed -E -n -e "s/^[[:space:]]*source(-file)?[[:space:]]+(-q+[[:space:]]+)?['\"]?([^'\"]+)['\"]?/\3/p"
-}
-
-# Want to be able to abort in certain cases
-trap "exit 1" TERM
-export TOP_PID=$$
-
-_fatal_error_abort() {
- echo >&2 "Aborting."
- kill -s TERM $TOP_PID
-}
-
-# PUBLIC FUNCTIONS BELOW
-
-tpm_path() {
- if [ "$_CACHED_TPM_PATH" == "/" ]; then
- echo >&2 "FATAL: Tmux Plugin Manager not configured in tmux.conf"
- _fatal_error_abort
- fi
- echo "$_CACHED_TPM_PATH"
-}
-
-tpm_plugins_list_helper() {
- # lists plugins from @tpm_plugins option
- echo "$(tmux start-server\; show-option -gqv "$tpm_plugins_variable_name")"
-
- # read set -g @plugin "tmux-plugins/tmux-example-plugin" entries
- _tmux_conf_contents "full" |
- awk '/^[ \t]*set(-option)? +-g +@plugin/ { gsub(/'\''/,""); gsub(/'\"'/,""); print $4 }'
-}
-
-# Allowed plugin name formats:
-# 1. "git://github.com/user/plugin_name.git"
-# 2. "user/plugin_name"
-plugin_name_helper() {
- local plugin="$1"
- # get only the part after the last slash, e.g. "plugin_name.git"
- local plugin_basename="$(basename "$plugin")"
- # remove ".git" extension (if it exists) to get only "plugin_name"
- local plugin_name="${plugin_basename%.git}"
- echo "$plugin_name"
-}
-
-plugin_path_helper() {
- local plugin="$1"
- local plugin_name="$(plugin_name_helper "$plugin")"
- echo "$(tpm_path)${plugin_name}/"
-}
-
-plugin_already_installed() {
- local plugin="$1"
- local plugin_path="$(plugin_path_helper "$plugin")"
- [ -d "$plugin_path" ] &&
- cd "$plugin_path" &&
- git remote >/dev/null 2>&1
-}
diff --git a/tmux/.tmux/plugins/tpm/scripts/helpers/shell_echo_functions.sh b/tmux/.tmux/plugins/tpm/scripts/helpers/shell_echo_functions.sh
deleted file mode 100644
index ecaa37e..0000000
--- a/tmux/.tmux/plugins/tpm/scripts/helpers/shell_echo_functions.sh
+++ /dev/null
@@ -1,7 +0,0 @@
-echo_ok() {
- echo "$*"
-}
-
-echo_err() {
- fail_helper "$*"
-}
diff --git a/tmux/.tmux/plugins/tpm/scripts/helpers/tmux_echo_functions.sh b/tmux/.tmux/plugins/tpm/scripts/helpers/tmux_echo_functions.sh
deleted file mode 100644
index 7a6ef0a..0000000
--- a/tmux/.tmux/plugins/tpm/scripts/helpers/tmux_echo_functions.sh
+++ /dev/null
@@ -1,28 +0,0 @@
-_has_emacs_mode_keys() {
- $(tmux show -gw mode-keys | grep -q emacs)
-}
-
-tmux_echo() {
- local message="$1"
- tmux run-shell "echo '$message'"
-}
-
-echo_ok() {
- tmux_echo "$*"
-}
-
-echo_err() {
- tmux_echo "$*"
-}
-
-end_message() {
- if _has_emacs_mode_keys; then
- local continue_key="ESCAPE"
- else
- local continue_key="ENTER"
- fi
- tmux_echo ""
- tmux_echo "TMUX environment reloaded."
- tmux_echo ""
- tmux_echo "Done, press $continue_key to continue."
-}
diff --git a/tmux/.tmux/plugins/tpm/scripts/helpers/tmux_utils.sh b/tmux/.tmux/plugins/tpm/scripts/helpers/tmux_utils.sh
deleted file mode 100644
index 238952d..0000000
--- a/tmux/.tmux/plugins/tpm/scripts/helpers/tmux_utils.sh
+++ /dev/null
@@ -1,6 +0,0 @@
-HELPERS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
-source "$HELPERS_DIR/plugin_functions.sh"
-
-reload_tmux_environment() {
- tmux source-file $(_get_user_tmux_conf) >/dev/null 2>&1
-}
diff --git a/tmux/.tmux/plugins/tpm/scripts/helpers/utility.sh b/tmux/.tmux/plugins/tpm/scripts/helpers/utility.sh
deleted file mode 100644
index de6eb35..0000000
--- a/tmux/.tmux/plugins/tpm/scripts/helpers/utility.sh
+++ /dev/null
@@ -1,17 +0,0 @@
-ensure_tpm_path_exists() {
- mkdir -p "$(tpm_path)"
-}
-
-fail_helper() {
- local message="$1"
- echo "$message" >&2
- FAIL="true"
-}
-
-exit_value_helper() {
- if [ "$FAIL" == "true" ]; then
- exit 1
- else
- exit 0
- fi
-}
diff --git a/tmux/.tmux/plugins/tpm/scripts/install_plugins.sh b/tmux/.tmux/plugins/tpm/scripts/install_plugins.sh
deleted file mode 100755
index e2450ac..0000000
--- a/tmux/.tmux/plugins/tpm/scripts/install_plugins.sh
+++ /dev/null
@@ -1,75 +0,0 @@
-#!/usr/bin/env bash
-
-CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
-HELPERS_DIR="$CURRENT_DIR/helpers"
-
-source "$HELPERS_DIR/plugin_functions.sh"
-source "$HELPERS_DIR/utility.sh"
-
-if [ "$1" == "--tmux-echo" ]; then # tmux-specific echo functions
- source "$HELPERS_DIR/tmux_echo_functions.sh"
-else # shell output functions
- source "$HELPERS_DIR/shell_echo_functions.sh"
-fi
-
-clone() {
- local plugin="$1"
- local branch="$2"
- if [ -n "$branch" ]; then
- cd "$(tpm_path)" &&
- GIT_TERMINAL_PROMPT=0 git clone -b "$branch" --single-branch --recursive "$plugin" >/dev/null 2>&1
- else
- cd "$(tpm_path)" &&
- GIT_TERMINAL_PROMPT=0 git clone --single-branch --recursive "$plugin" >/dev/null 2>&1
- fi
-}
-
-# tries cloning:
-# 1. plugin name directly - works if it's a valid git url
-# 2. expands the plugin name to point to a GitHub repo and tries cloning again
-clone_plugin() {
- local plugin="$1"
- local branch="$2"
- clone "$plugin" "$branch" ||
- clone "https://git::@github.com/$plugin" "$branch"
-}
-
-# clone plugin and produce output
-install_plugin() {
- local plugin="$1"
- local branch="$2"
- local plugin_name="$(plugin_name_helper "$plugin")"
-
- if plugin_already_installed "$plugin"; then
- echo_ok "Already installed \"$plugin_name\""
- else
- echo_ok "Installing \"$plugin_name\""
- clone_plugin "$plugin" "$branch" &&
- echo_ok " \"$plugin_name\" download success" ||
- echo_err " \"$plugin_name\" download fail"
- fi
-}
-
-install_plugins() {
- local plugins="$(tpm_plugins_list_helper)"
- for plugin in $plugins; do
- IFS='#' read -ra plugin <<< "$plugin"
- install_plugin "${plugin[0]}" "${plugin[1]}"
- done
-}
-
-verify_tpm_path_permissions() {
- local path="$(tpm_path)"
- # check the write permission flag for all users to ensure
- # that we have proper access
- [ -w "$path" ] ||
- echo_err "$path is not writable!"
-}
-
-main() {
- ensure_tpm_path_exists
- verify_tpm_path_permissions
- install_plugins
- exit_value_helper
-}
-main
diff --git a/tmux/.tmux/plugins/tpm/scripts/source_plugins.sh b/tmux/.tmux/plugins/tpm/scripts/source_plugins.sh
deleted file mode 100755
index 6381d54..0000000
--- a/tmux/.tmux/plugins/tpm/scripts/source_plugins.sh
+++ /dev/null
@@ -1,42 +0,0 @@
-#!/usr/bin/env bash
-
-CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
-HELPERS_DIR="$CURRENT_DIR/helpers"
-
-source "$HELPERS_DIR/plugin_functions.sh"
-
-plugin_dir_exists() {
- [ -d "$1" ]
-}
-
-# Runs all *.tmux files from the plugin directory.
-# Files are ran as executables.
-# No errors if the plugin dir does not exist.
-silently_source_all_tmux_files() {
- local plugin_path="$1"
- local plugin_tmux_files="$plugin_path*.tmux"
- if plugin_dir_exists "$plugin_path"; then
- for tmux_file in $plugin_tmux_files; do
- # if the glob didn't find any files this will be the
- # unexpanded glob which obviously doesn't exist
- [ -f "$tmux_file" ] || continue
- # runs *.tmux file as an executable
- $tmux_file >/dev/null 2>&1
- done
- fi
-}
-
-source_plugins() {
- local plugin plugin_path
- local plugins="$(tpm_plugins_list_helper)"
- for plugin in $plugins; do
- IFS='#' read -ra plugin <<< "$plugin"
- plugin_path="$(plugin_path_helper "${plugin[0]}")"
- silently_source_all_tmux_files "$plugin_path"
- done
-}
-
-main() {
- source_plugins
-}
-main
diff --git a/tmux/.tmux/plugins/tpm/scripts/update_plugin.sh b/tmux/.tmux/plugins/tpm/scripts/update_plugin.sh
deleted file mode 100755
index e533664..0000000
--- a/tmux/.tmux/plugins/tpm/scripts/update_plugin.sh
+++ /dev/null
@@ -1,78 +0,0 @@
-#!/usr/bin/env bash
-
-# this script handles core logic of updating plugins
-
-CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
-HELPERS_DIR="$CURRENT_DIR/helpers"
-
-source "$HELPERS_DIR/plugin_functions.sh"
-source "$HELPERS_DIR/utility.sh"
-
-if [ "$1" == "--tmux-echo" ]; then # tmux-specific echo functions
- source "$HELPERS_DIR/tmux_echo_functions.sh"
-else # shell output functions
- source "$HELPERS_DIR/shell_echo_functions.sh"
-fi
-
-# from now on ignore first script argument
-shift
-
-pull_changes() {
- local plugin="$1"
- local plugin_path="$(plugin_path_helper "$plugin")"
- cd "$plugin_path" &&
- GIT_TERMINAL_PROMPT=0 git pull &&
- GIT_TERMINAL_PROMPT=0 git submodule update --init --recursive
-}
-
-update() {
- local plugin="$1" output
- output=$(pull_changes "$plugin" 2>&1)
- if (( $? == 0 )); then
- echo_ok " \"$plugin\" update success"
- echo_ok "$(echo "$output" | sed -e 's/^/ | /')"
- else
- echo_err " \"$plugin\" update fail"
- echo_err "$(echo "$output" | sed -e 's/^/ | /')"
- fi
-}
-
-update_all() {
- echo_ok "Updating all plugins!"
- echo_ok ""
- local plugins="$(tpm_plugins_list_helper)"
- for plugin in $plugins; do
- IFS='#' read -ra plugin <<< "$plugin"
- local plugin_name="$(plugin_name_helper "${plugin[0]}")"
- # updating only installed plugins
- if plugin_already_installed "$plugin_name"; then
- update "$plugin_name" &
- fi
- done
- wait
-}
-
-update_plugins() {
- local plugins="$*"
- for plugin in $plugins; do
- IFS='#' read -ra plugin <<< "$plugin"
- local plugin_name="$(plugin_name_helper "${plugin[0]}")"
- if plugin_already_installed "$plugin_name"; then
- update "$plugin_name" &
- else
- echo_err "$plugin_name not installed!" &
- fi
- done
- wait
-}
-
-main() {
- ensure_tpm_path_exists
- if [ "$1" == "all" ]; then
- update_all
- else
- update_plugins "$*"
- fi
- exit_value_helper
-}
-main "$*"
diff --git a/tmux/.tmux/plugins/tpm/scripts/update_plugin_prompt_handler.sh b/tmux/.tmux/plugins/tpm/scripts/update_plugin_prompt_handler.sh
deleted file mode 100755
index 5e1f7d9..0000000
--- a/tmux/.tmux/plugins/tpm/scripts/update_plugin_prompt_handler.sh
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/usr/bin/env bash
-
-CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
-HELPERS_DIR="$CURRENT_DIR/helpers"
-
-if [ $# -eq 0 ]; then
- exit 0
-fi
-
-source "$HELPERS_DIR/tmux_echo_functions.sh"
-source "$HELPERS_DIR/tmux_utils.sh"
-
-main() {
- "$CURRENT_DIR/update_plugin.sh" --tmux-echo "$*"
- reload_tmux_environment
- end_message
-}
-main "$*"
diff --git a/tmux/.tmux/plugins/tpm/scripts/variables.sh b/tmux/.tmux/plugins/tpm/scripts/variables.sh
deleted file mode 100644
index 5601a86..0000000
--- a/tmux/.tmux/plugins/tpm/scripts/variables.sh
+++ /dev/null
@@ -1,13 +0,0 @@
-install_key_option="@tpm-install"
-default_install_key="I"
-
-update_key_option="@tpm-update"
-default_update_key="U"
-
-clean_key_option="@tpm-clean"
-default_clean_key="M-u"
-
-SUPPORTED_TMUX_VERSION="1.9"
-
-DEFAULT_TPM_ENV_VAR_NAME="TMUX_PLUGIN_MANAGER_PATH"
-DEFAULT_TPM_PATH="$HOME/.tmux/plugins/"