Use the running tmux server to get @plugins or start a new server
I normally start my tmux server with a script because I don't have a .tmux.config. i.e., tmux set -g @plugin 'tmux-plugins/tmux-resurrect' \; ... This change makes it so that @plugins is sourced from the currently running tmux server instead of spinning up a new one. This also means that we no longer need to manually parse the configs. There was also a problem that _tpm_path would not work correctly if using $XDG_CONFIG_HOME/tmux/tmux.conf because tmux by default doesn't check that path. I tested this with both inside and outside tmux by running ./tpm/bin/install_plugin
This commit is contained in:
parent
33c5d9a3af
commit
5edba1c1d1
1 changed files with 9 additions and 20 deletions
|
@ -18,21 +18,13 @@ _get_user_tmux_conf() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
_tmux_conf_contents() {
|
_exec_tmux() {
|
||||||
user_config=$(_get_user_tmux_conf)
|
local OPTS=()
|
||||||
cat /etc/tmux.conf "$user_config" 2>/dev/null
|
if [[ -z "$TMUX" ]]; then
|
||||||
if [ "$1" == "full" ]; then # also output content from sourced files
|
OPTS+=(-f "$(_get_user_tmux_conf)" start-server \;)
|
||||||
local file
|
|
||||||
for file in $(_sourced_files); do
|
|
||||||
cat $(_manual_expansion "$file") 2>/dev/null
|
|
||||||
done
|
|
||||||
fi
|
fi
|
||||||
}
|
|
||||||
|
|
||||||
# return files sourced from tmux config files
|
tmux "${OPTS[@]}" "${@}"
|
||||||
_sourced_files() {
|
|
||||||
_tmux_conf_contents |
|
|
||||||
awk '/^[ \t]*source(-file)? +/ { gsub(/'\''/,""); gsub(/'\"'/,""); print $2 }'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# manually expanding tilde char or `$HOME` variable.
|
# manually expanding tilde char or `$HOME` variable.
|
||||||
|
@ -43,7 +35,7 @@ _manual_expansion() {
|
||||||
}
|
}
|
||||||
|
|
||||||
_tpm_path() {
|
_tpm_path() {
|
||||||
local string_path="$(tmux start-server\; show-environment -g TMUX_PLUGIN_MANAGER_PATH | cut -f2 -d=)/"
|
local string_path="$(_exec_tmux show-environment -g TMUX_PLUGIN_MANAGER_PATH | cut -f2 -d=)/"
|
||||||
_manual_expansion "$string_path"
|
_manual_expansion "$string_path"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,12 +61,9 @@ tpm_path() {
|
||||||
}
|
}
|
||||||
|
|
||||||
tpm_plugins_list_helper() {
|
tpm_plugins_list_helper() {
|
||||||
# lists plugins from @tpm_plugins option
|
# lists plugins from @tpm_plugins option and @plugins
|
||||||
echo "$(tmux start-server\; show-option -gqv "$tpm_plugins_variable_name")"
|
_exec_tmux show-option -gqv "$tpm_plugins_variable_name" \; \
|
||||||
|
show-option -gqv "@plugin" \;
|
||||||
# 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:
|
# Allowed plugin name formats:
|
||||||
|
|
Loading…
Reference in a new issue