Switching to tab indentation
This commit is contained in:
parent
0e04c1f34f
commit
77747b8e02
5 changed files with 86 additions and 86 deletions
|
@ -3,20 +3,20 @@
|
||||||
default_tpm_path="$HOME/.tmux/plugins/"
|
default_tpm_path="$HOME/.tmux/plugins/"
|
||||||
|
|
||||||
tpm_path_set() {
|
tpm_path_set() {
|
||||||
tmux show-environment -g TMUX_PLUGIN_MANAGER_PATH
|
tmux show-environment -g TMUX_PLUGIN_MANAGER_PATH
|
||||||
}
|
}
|
||||||
|
|
||||||
set_default_tpm_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() {
|
ensure_tpm_path() {
|
||||||
if ! tpm_path_set; then
|
if ! tpm_path_set; then
|
||||||
set_default_tpm_path
|
set_default_tpm_path
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
ensure_tpm_path
|
ensure_tpm_path
|
||||||
}
|
}
|
||||||
main
|
main
|
||||||
|
|
|
@ -5,27 +5,27 @@ SHARED_TPM_PATH=""
|
||||||
|
|
||||||
# sets a "global variable" for the current file
|
# sets a "global variable" for the current file
|
||||||
shared_set_tpm_path_constant() {
|
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() {
|
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:
|
# Allowed plugin name formats:
|
||||||
# 1. "git://github.com/user/plugin_name.git"
|
# 1. "git://github.com/user/plugin_name.git"
|
||||||
# 2. "user/plugin_name"
|
# 2. "user/plugin_name"
|
||||||
shared_plugin_name() {
|
shared_plugin_name() {
|
||||||
local plugin=$1
|
local plugin=$1
|
||||||
# get only the part after the last slash, e.g. "plugin_name.git"
|
# get only the part after the last slash, e.g. "plugin_name.git"
|
||||||
local plugin_basename=$(basename "$plugin")
|
local plugin_basename=$(basename "$plugin")
|
||||||
# remove ".git" extension (if it exists) to get only "plugin_name"
|
# remove ".git" extension (if it exists) to get only "plugin_name"
|
||||||
local plugin_name=${plugin_basename%.git}
|
local plugin_name=${plugin_basename%.git}
|
||||||
echo $plugin_name
|
echo $plugin_name
|
||||||
}
|
}
|
||||||
|
|
||||||
shared_plugin_path() {
|
shared_plugin_path() {
|
||||||
local plugin=$1
|
local plugin=$1
|
||||||
local plugin_name=$(shared_plugin_name "$plugin")
|
local plugin_name=$(shared_plugin_name "$plugin")
|
||||||
echo "$SHARED_TPM_PATH$plugin_name/"
|
echo "$SHARED_TPM_PATH$plugin_name/"
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,29 +8,29 @@ source "$CURRENT_DIR/shared_functions.sh"
|
||||||
# Files are ran as executables.
|
# Files are ran as executables.
|
||||||
# No errors if the plugin dir does not exist.
|
# No errors if the plugin dir does not exist.
|
||||||
silently_source_all_tmux_files() {
|
silently_source_all_tmux_files() {
|
||||||
local plugin_path=$1
|
local plugin_path=$1
|
||||||
local plugin_tmux_files="$plugin_path*.tmux"
|
local plugin_tmux_files="$plugin_path*.tmux"
|
||||||
for tmux_file in $plugin_tmux_files; do
|
for tmux_file in $plugin_tmux_files; do
|
||||||
# runs *.tmux file as an executable
|
# runs *.tmux file as an executable
|
||||||
$tmux_file >/dev/null 2>&1
|
$tmux_file >/dev/null 2>&1
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
source_plugin() {
|
source_plugin() {
|
||||||
local plugin=$1
|
local plugin=$1
|
||||||
local plugin_path=$(shared_plugin_path "$plugin")
|
local plugin_path=$(shared_plugin_path "$plugin")
|
||||||
silently_source_all_tmux_files "$plugin_path"
|
silently_source_all_tmux_files "$plugin_path"
|
||||||
}
|
}
|
||||||
|
|
||||||
source_plugins() {
|
source_plugins() {
|
||||||
local plugins=$(shared_get_tpm_plugins_list)
|
local plugins=$(shared_get_tpm_plugins_list)
|
||||||
for plugin in $plugins; do
|
for plugin in $plugins; do
|
||||||
source_plugin "$plugin"
|
source_plugin "$plugin"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
shared_set_tpm_path_constant
|
shared_set_tpm_path_constant
|
||||||
source_plugins
|
source_plugins
|
||||||
}
|
}
|
||||||
main
|
main
|
||||||
|
|
|
@ -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
|
# TMUX messaging is weird. You only get a nice clean pane if you do it with
|
||||||
# `run-shell` command.
|
# `run-shell` command.
|
||||||
display_message() {
|
display_message() {
|
||||||
local message=$1
|
local message=$1
|
||||||
tmux run-shell "echo '$message'"
|
tmux run-shell "echo '$message'"
|
||||||
}
|
}
|
||||||
|
|
||||||
end_message() {
|
end_message() {
|
||||||
display_message ""
|
display_message ""
|
||||||
display_message "TMUX environment reloaded."
|
display_message "TMUX environment reloaded."
|
||||||
display_message ""
|
display_message ""
|
||||||
display_message "Done, press ENTER to continue."
|
display_message "Done, press ENTER to continue."
|
||||||
}
|
}
|
||||||
|
|
||||||
clone() {
|
clone() {
|
||||||
local plugin=$1
|
local plugin=$1
|
||||||
cd $SHARED_TPM_PATH &&
|
cd $SHARED_TPM_PATH &&
|
||||||
git clone --recursive $plugin
|
git clone --recursive $plugin
|
||||||
}
|
}
|
||||||
|
|
||||||
# tries cloning:
|
# tries cloning:
|
||||||
# 1. plugin name directly - works if it's a valid git url
|
# 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
|
# 2. expands the plugin name to point to a github repo and tries cloning again
|
||||||
clone_plugin() {
|
clone_plugin() {
|
||||||
local plugin=$1
|
local plugin=$1
|
||||||
clone "$plugin" ||
|
clone "$plugin" ||
|
||||||
clone "https://github.com/$plugin"
|
clone "https://github.com/$plugin"
|
||||||
}
|
}
|
||||||
|
|
||||||
plugin_already_cloned() {
|
plugin_already_cloned() {
|
||||||
local plugin=$1
|
local plugin=$1
|
||||||
local plugin_path=$(shared_plugin_path "$plugin")
|
local plugin_path=$(shared_plugin_path "$plugin")
|
||||||
cd $plugin_path &&
|
cd $plugin_path &&
|
||||||
git remote
|
git remote
|
||||||
}
|
}
|
||||||
|
|
||||||
pull_changes() {
|
pull_changes() {
|
||||||
local plugin=$1
|
local plugin=$1
|
||||||
local plugin_path=$(shared_plugin_path "$plugin")
|
local plugin_path=$(shared_plugin_path "$plugin")
|
||||||
cd $plugin_path &&
|
cd $plugin_path &&
|
||||||
git pull &&
|
git pull &&
|
||||||
git submodule update --init --recursive
|
git submodule update --init --recursive
|
||||||
}
|
}
|
||||||
|
|
||||||
# pull new changes or clone plugin
|
# pull new changes or clone plugin
|
||||||
sync_plugin() {
|
sync_plugin() {
|
||||||
local plugin=$1
|
local plugin=$1
|
||||||
if plugin_already_cloned "$plugin"; then
|
if plugin_already_cloned "$plugin"; then
|
||||||
# plugin is already cloned - update it
|
# plugin is already cloned - update it
|
||||||
display_message "Updating $plugin"
|
display_message "Updating $plugin"
|
||||||
pull_changes "$plugin" &&
|
pull_changes "$plugin" &&
|
||||||
display_message " $plugin update success" ||
|
display_message " $plugin update success" ||
|
||||||
display_message " $plugin update fail"
|
display_message " $plugin update fail"
|
||||||
else
|
else
|
||||||
# plugin wasn't cloned so far - clone it
|
# plugin wasn't cloned so far - clone it
|
||||||
display_message "Downloading $plugin"
|
display_message "Downloading $plugin"
|
||||||
clone_plugin "$plugin" &&
|
clone_plugin "$plugin" &&
|
||||||
display_message " $plugin download success" ||
|
display_message " $plugin download success" ||
|
||||||
display_message " $plugin download fail"
|
display_message " $plugin download fail"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
sync_plugins() {
|
sync_plugins() {
|
||||||
local plugins=$(shared_get_tpm_plugins_list)
|
local plugins=$(shared_get_tpm_plugins_list)
|
||||||
for plugin in $plugins; do
|
for plugin in $plugins; do
|
||||||
sync_plugin "$plugin"
|
sync_plugin "$plugin"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
ensure_tpm_path_exists() {
|
ensure_tpm_path_exists() {
|
||||||
mkdir -p $SHARED_TPM_PATH
|
mkdir -p $SHARED_TPM_PATH
|
||||||
}
|
}
|
||||||
|
|
||||||
reload_tmux_environment() {
|
reload_tmux_environment() {
|
||||||
tmux source-file ~/.tmux.conf >/dev/null 2>&1
|
tmux source-file ~/.tmux.conf >/dev/null 2>&1
|
||||||
}
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
reload_tmux_environment
|
reload_tmux_environment
|
||||||
shared_set_tpm_path_constant
|
shared_set_tpm_path_constant
|
||||||
ensure_tpm_path_exists
|
ensure_tpm_path_exists
|
||||||
sync_plugins
|
sync_plugins
|
||||||
reload_tmux_environment
|
reload_tmux_environment
|
||||||
end_message
|
end_message
|
||||||
}
|
}
|
||||||
main
|
main
|
||||||
|
|
14
tpm
14
tpm
|
@ -9,27 +9,27 @@ CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
# Put this in `.tmux.conf` to override the default:
|
# Put this in `.tmux.conf` to override the default:
|
||||||
# `set-environment -g TMUX_PLUGIN_MANAGER_PATH "/some/other/path/"`
|
# `set-environment -g TMUX_PLUGIN_MANAGER_PATH "/some/other/path/"`
|
||||||
set_tpm_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.
|
# 1. Fetches plugin names from `@tpm_plugins` user variable.
|
||||||
# 2. Creates full plugin path
|
# 2. Creates full plugin path
|
||||||
# 3. Sources all *.tmux files from each of the plugin directories
|
# 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!
|
# Files are sourced as tmux config files, not as shell scripts!
|
||||||
source_plugins() {
|
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:
|
# Defines key binding:
|
||||||
# prefix + I - downloads TPM plugins and reloads TMUX environment.
|
# prefix + I - downloads TPM plugins and reloads TMUX environment.
|
||||||
set_tpm_key_binding() {
|
set_tpm_key_binding() {
|
||||||
$CURRENT_DIR/scripts/key_binding.sh
|
$CURRENT_DIR/scripts/key_binding.sh
|
||||||
}
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
set_tpm_path
|
set_tpm_path
|
||||||
set_tpm_key_binding
|
set_tpm_key_binding
|
||||||
source_plugins
|
source_plugins
|
||||||
}
|
}
|
||||||
main
|
main
|
||||||
|
|
Loading…
Reference in a new issue