Merge 913f29af86
into 99469c4a9b
This commit is contained in:
commit
2181d14717
|
@ -15,7 +15,7 @@ Requirements: `tmux` version 1.9 (or higher), `git`, `bash`.
|
||||||
Clone TPM:
|
Clone TPM:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
|
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tmux-plugins/tpm
|
||||||
```
|
```
|
||||||
|
|
||||||
Put this at the bottom of `~/.tmux.conf` (`$XDG_CONFIG_HOME/tmux/tmux.conf`
|
Put this at the bottom of `~/.tmux.conf` (`$XDG_CONFIG_HOME/tmux/tmux.conf`
|
||||||
|
@ -28,12 +28,12 @@ set -g @plugin 'tmux-plugins/tmux-sensible'
|
||||||
|
|
||||||
# Other examples:
|
# Other examples:
|
||||||
# set -g @plugin 'github_username/plugin_name'
|
# set -g @plugin 'github_username/plugin_name'
|
||||||
# set -g @plugin 'github_username/plugin_name#branch'
|
# set -g @plugin 'github_username/plugin_name#branch_or_tag'
|
||||||
# set -g @plugin 'git@github.com:user/plugin'
|
# set -g @plugin 'git@github.com:user/plugin'
|
||||||
# set -g @plugin 'git@bitbucket.com:user/plugin'
|
# set -g @plugin 'git@bitbucket.com:user/plugin'
|
||||||
|
|
||||||
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
|
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
|
||||||
run '~/.tmux/plugins/tpm/tpm'
|
run '~/.tmux/plugins/tmux-plugins/tpm/tpm'
|
||||||
```
|
```
|
||||||
|
|
||||||
Reload TMUX environment so TPM is sourced:
|
Reload TMUX environment so TPM is sourced:
|
||||||
|
|
|
@ -82,10 +82,11 @@ tpm_plugins_list_helper() {
|
||||||
# 2. "user/plugin_name"
|
# 2. "user/plugin_name"
|
||||||
plugin_name_helper() {
|
plugin_name_helper() {
|
||||||
local plugin="$1"
|
local plugin="$1"
|
||||||
# get only the part after the last slash, e.g. "plugin_name.git"
|
# get only the last part
|
||||||
local plugin_basename="$(basename "$plugin")"
|
IFS='/' read -ra plugin <<< "$plugin"
|
||||||
|
plugin="${plugin[-2]}/${plugin[-1]}"
|
||||||
# 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%.git}"
|
||||||
echo "$plugin_name"
|
echo "$plugin_name"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,7 +98,8 @@ plugin_path_helper() {
|
||||||
|
|
||||||
plugin_already_installed() {
|
plugin_already_installed() {
|
||||||
local plugin="$1"
|
local plugin="$1"
|
||||||
local plugin_path="$(plugin_path_helper "$plugin")"
|
IFS='#' read -ra plugin <<< "$plugin"
|
||||||
|
local plugin_path="$(plugin_path_helper "${plugin[0]}")"
|
||||||
[ -d "$plugin_path" ] &&
|
[ -d "$plugin_path" ] &&
|
||||||
cd "$plugin_path" &&
|
cd "$plugin_path" &&
|
||||||
git remote >/dev/null 2>&1
|
git remote >/dev/null 2>&1
|
||||||
|
|
|
@ -14,19 +14,18 @@ fi
|
||||||
|
|
||||||
clone() {
|
clone() {
|
||||||
local plugin="$1"
|
local plugin="$1"
|
||||||
local branch="$2"
|
[[ -z "$2" ]] && local branch="" || local branch="--branch $2"
|
||||||
if [ -n "$branch" ]; then
|
if [[ ! $plugin == *"https://"* ]]; then
|
||||||
cd "$(tpm_path)" &&
|
cd "$(tpm_path)" &&
|
||||||
GIT_TERMINAL_PROMPT=0 git clone -b "$branch" --single-branch --recursive "$plugin" >/dev/null 2>&1
|
GIT_TERMINAL_PROMPT=0 git clone $branch --single-branch --recursive "https://git::@github.com/$plugin" $plugin >/dev/null 2>&1
|
||||||
else
|
else
|
||||||
|
local basename_with_git="$(basename "$plugin")"
|
||||||
|
local basename="${basename_with_git%.git}"
|
||||||
cd "$(tpm_path)" &&
|
cd "$(tpm_path)" &&
|
||||||
GIT_TERMINAL_PROMPT=0 git clone --single-branch --recursive "$plugin" >/dev/null 2>&1
|
GIT_TERMINAL_PROMPT=0 git clone $branch --single-branch --recursive "$basename" $basename >/dev/null 2>&1
|
||||||
fi
|
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() {
|
clone_plugin() {
|
||||||
local plugin="$1"
|
local plugin="$1"
|
||||||
local branch="$2"
|
local branch="$2"
|
||||||
|
|
Loading…
Reference in a new issue