From 77747b8e02d183648da6ae74ec76d3a419f30f21 Mon Sep 17 00:00:00 2001 From: Bruno Sutic Date: Sat, 24 May 2014 23:15:13 +0200 Subject: [PATCH] Switching to tab indentation --- scripts/set_tpm_path.sh | 12 ++--- scripts/shared_functions.sh | 22 ++++----- scripts/source_plugins.sh | 30 ++++++------ scripts/sync_plugins.sh | 94 ++++++++++++++++++------------------- tpm | 14 +++--- 5 files changed, 86 insertions(+), 86 deletions(-) diff --git a/scripts/set_tpm_path.sh b/scripts/set_tpm_path.sh index 2229320..a241636 100755 --- a/scripts/set_tpm_path.sh +++ b/scripts/set_tpm_path.sh @@ -3,20 +3,20 @@ default_tpm_path="$HOME/.tmux/plugins/" tpm_path_set() { - tmux show-environment -g TMUX_PLUGIN_MANAGER_PATH + tmux show-environment -g TMUX_PLUGIN_MANAGER_PATH } set_default_tpm_path() { - tmux set-environment -g TMUX_PLUGIN_MANAGER_PATH "$default_tpm_path" + tmux set-environment -g TMUX_PLUGIN_MANAGER_PATH "$default_tpm_path" } ensure_tpm_path() { - if ! tpm_path_set; then - set_default_tpm_path - fi + if ! tpm_path_set; then + set_default_tpm_path + fi } main() { - ensure_tpm_path + ensure_tpm_path } main diff --git a/scripts/shared_functions.sh b/scripts/shared_functions.sh index 6e22542..8beae6f 100644 --- a/scripts/shared_functions.sh +++ b/scripts/shared_functions.sh @@ -5,27 +5,27 @@ SHARED_TPM_PATH="" # sets a "global variable" for the current file shared_set_tpm_path_constant() { - SHARED_TPM_PATH=$(tmux show-environment -g TMUX_PLUGIN_MANAGER_PATH | cut -f2 -d=) + SHARED_TPM_PATH=$(tmux show-environment -g TMUX_PLUGIN_MANAGER_PATH | cut -f2 -d=) } shared_get_tpm_plugins_list() { - tmux show-option -gqv "$tpm_plugins_variable_name" + tmux show-option -gqv "$tpm_plugins_variable_name" } # Allowed plugin name formats: # 1. "git://github.com/user/plugin_name.git" # 2. "user/plugin_name" shared_plugin_name() { - 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 + 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 } shared_plugin_path() { - local plugin=$1 - local plugin_name=$(shared_plugin_name "$plugin") - echo "$SHARED_TPM_PATH$plugin_name/" + local plugin=$1 + local plugin_name=$(shared_plugin_name "$plugin") + echo "$SHARED_TPM_PATH$plugin_name/" } diff --git a/scripts/source_plugins.sh b/scripts/source_plugins.sh index 483ec7e..96f76c0 100755 --- a/scripts/source_plugins.sh +++ b/scripts/source_plugins.sh @@ -8,29 +8,29 @@ source "$CURRENT_DIR/shared_functions.sh" # 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" - for tmux_file in $plugin_tmux_files; do - # runs *.tmux file as an executable - $tmux_file >/dev/null 2>&1 - done + local plugin_path=$1 + local plugin_tmux_files="$plugin_path*.tmux" + for tmux_file in $plugin_tmux_files; do + # runs *.tmux file as an executable + $tmux_file >/dev/null 2>&1 + done } source_plugin() { - local plugin=$1 - local plugin_path=$(shared_plugin_path "$plugin") - silently_source_all_tmux_files "$plugin_path" + local plugin=$1 + local plugin_path=$(shared_plugin_path "$plugin") + silently_source_all_tmux_files "$plugin_path" } source_plugins() { - local plugins=$(shared_get_tpm_plugins_list) - for plugin in $plugins; do - source_plugin "$plugin" - done + local plugins=$(shared_get_tpm_plugins_list) + for plugin in $plugins; do + source_plugin "$plugin" + done } main() { - shared_set_tpm_path_constant - source_plugins + shared_set_tpm_path_constant + source_plugins } main diff --git a/scripts/sync_plugins.sh b/scripts/sync_plugins.sh index 92858f4..0db265a 100755 --- a/scripts/sync_plugins.sh +++ b/scripts/sync_plugins.sh @@ -7,86 +7,86 @@ source "$CURRENT_DIR/shared_functions.sh" # TMUX messaging is weird. You only get a nice clean pane if you do it with # `run-shell` command. display_message() { - local message=$1 - tmux run-shell "echo '$message'" + local message=$1 + tmux run-shell "echo '$message'" } end_message() { - display_message "" - display_message "TMUX environment reloaded." - display_message "" - display_message "Done, press ENTER to continue." + display_message "" + display_message "TMUX environment reloaded." + display_message "" + display_message "Done, press ENTER to continue." } clone() { - local plugin=$1 - cd $SHARED_TPM_PATH && - git clone --recursive $plugin + local plugin=$1 + cd $SHARED_TPM_PATH && + git clone --recursive $plugin } # 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 - clone "$plugin" || - clone "https://github.com/$plugin" + local plugin=$1 + clone "$plugin" || + clone "https://github.com/$plugin" } plugin_already_cloned() { - local plugin=$1 - local plugin_path=$(shared_plugin_path "$plugin") - cd $plugin_path && - git remote + local plugin=$1 + local plugin_path=$(shared_plugin_path "$plugin") + cd $plugin_path && + git remote } pull_changes() { - local plugin=$1 - local plugin_path=$(shared_plugin_path "$plugin") - cd $plugin_path && - git pull && - git submodule update --init --recursive + local plugin=$1 + local plugin_path=$(shared_plugin_path "$plugin") + cd $plugin_path && + git pull && + git submodule update --init --recursive } # pull new changes or clone plugin sync_plugin() { - local plugin=$1 - if plugin_already_cloned "$plugin"; then - # plugin is already cloned - update it - display_message "Updating $plugin" - pull_changes "$plugin" && - display_message " $plugin update success" || - display_message " $plugin update fail" - else - # plugin wasn't cloned so far - clone it - display_message "Downloading $plugin" - clone_plugin "$plugin" && - display_message " $plugin download success" || - display_message " $plugin download fail" - fi + local plugin=$1 + if plugin_already_cloned "$plugin"; then + # plugin is already cloned - update it + display_message "Updating $plugin" + pull_changes "$plugin" && + display_message " $plugin update success" || + display_message " $plugin update fail" + else + # plugin wasn't cloned so far - clone it + display_message "Downloading $plugin" + clone_plugin "$plugin" && + display_message " $plugin download success" || + display_message " $plugin download fail" + fi } sync_plugins() { - local plugins=$(shared_get_tpm_plugins_list) - for plugin in $plugins; do - sync_plugin "$plugin" - done + local plugins=$(shared_get_tpm_plugins_list) + for plugin in $plugins; do + sync_plugin "$plugin" + done } ensure_tpm_path_exists() { - mkdir -p $SHARED_TPM_PATH + mkdir -p $SHARED_TPM_PATH } reload_tmux_environment() { - tmux source-file ~/.tmux.conf >/dev/null 2>&1 + tmux source-file ~/.tmux.conf >/dev/null 2>&1 } main() { - reload_tmux_environment - shared_set_tpm_path_constant - ensure_tpm_path_exists - sync_plugins - reload_tmux_environment - end_message + reload_tmux_environment + shared_set_tpm_path_constant + ensure_tpm_path_exists + sync_plugins + reload_tmux_environment + end_message } main diff --git a/tpm b/tpm index 92199fa..58b0143 100755 --- a/tpm +++ b/tpm @@ -9,27 +9,27 @@ CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" # Put this in `.tmux.conf` to override the default: # `set-environment -g TMUX_PLUGIN_MANAGER_PATH "/some/other/path/"` set_tpm_path() { - $CURRENT_DIR/scripts/set_tpm_path.sh >/dev/null 2>&1 + $CURRENT_DIR/scripts/set_tpm_path.sh >/dev/null 2>&1 } # 1. Fetches plugin names from `@tpm_plugins` user variable. # 2. Creates full plugin path # 3. Sources all *.tmux files from each of the plugin directories -# - no errors raised if directory does not exist +# - no errors raised if directory does not exist # Files are sourced as tmux config files, not as shell scripts! source_plugins() { - $CURRENT_DIR/scripts/source_plugins.sh >/dev/null 2>&1 + $CURRENT_DIR/scripts/source_plugins.sh >/dev/null 2>&1 } # Defines key binding: # prefix + I - downloads TPM plugins and reloads TMUX environment. set_tpm_key_binding() { - $CURRENT_DIR/scripts/key_binding.sh + $CURRENT_DIR/scripts/key_binding.sh } main() { - set_tpm_path - set_tpm_key_binding - source_plugins + set_tpm_path + set_tpm_key_binding + source_plugins } main