1
0
Fork 0
mirror of synced 2024-12-21 14:31:05 -05:00

updated tpm integration

- automatically delete tpm when not used
- automatically delete unused plugins
- install plugins when subsequently enabling then in ~/.tmux.conf.local
- use <prefix> + u to update plugins as <prefix> + U is bound to Urlview, fixes #507
This commit is contained in:
Gregory Pakosz 2021-09-04 18:00:02 +02:00
parent 4f332e6b17
commit a97e3021cc
3 changed files with 59 additions and 32 deletions

View file

@ -1339,37 +1339,53 @@ run 'cut -c3- ~/.tmux.conf | sh -s _apply_configuration'
# window_active="$1" # window_active="$1"
# tmux_conf_update_plugins_on_launch="$2" # tmux_conf_update_plugins_on_launch="$2"
# tmux_conf_update_plugins_on_reload="$3" # tmux_conf_update_plugins_on_reload="$3"
# tmux_conf_uninstall_plugins_on_reload="$4"
# #
# TMUX_PLUGIN_MANAGER_PATH=${TMUX_PLUGIN_MANAGER_PATH:-~/.tmux/plugins} # TMUX_PLUGIN_MANAGER_PATH=${TMUX_PLUGIN_MANAGER_PATH:-~/.tmux/plugins}
# # if [ -z "$(tmux show -gv '@plugin')" ] && [ -z "$(tmux show -gv '@tpm_plugins')" ]; then
# if curl -Ikfs -o /dev/null --connect-timeout 2 --max-time 2 https://github.com; then # if _is_enabled "$tmux_conf_uninstall_plugins_on_reload" && [ -d "$TMUX_PLUGIN_MANAGER_PATH/tpm" ]; then
# if [ ! -d "$TMUX_PLUGIN_MANAGER_PATH/tpm" ]; then # tmux display 'Uninstalling tpm and plugins...'
# install_tpm=true # rm -rf "$TMUX_PLUGIN_MANAGER_PATH"
# tmux display 'Installing tpm and plugins...' # tmux display 'Done uninstalling tpm and plugins...'
# git clone --depth 1 https://github.com/tmux-plugins/tpm "$TMUX_PLUGIN_MANAGER_PATH/tpm"
# elif { [ -z "$window_active" ] && _is_enabled "$tmux_conf_update_plugins_on_launch"; } || { [ -n "$window_active" ] && _is_enabled "$tmux_conf_update_plugins_on_reload"; }; then
# update_tpm=true
# tmux display 'Updating tpm and plugins...'
# (cd "$TMUX_PLUGIN_MANAGER_PATH/tpm" && git checkout -q master && git reset -q --hard HEAD && git pull -q origin master)
# fi
# if [ x"$install_tpm" = x"true" ] || [ x"$update_tpm" = x"true" ]; then
# perl -0777 -p -i -e 's/git clone --recursive/git clone --recursive --depth 1 --shallow-submodules/g
# ;s/(install_plugin "\$plugin")\n(\s+)done/\1&\n\2done\n\2wait/g' "$TMUX_PLUGIN_MANAGER_PATH/tpm/scripts/install_plugins.sh"
# perl -p -i -e 's/git submodule update --init --recursive/git submodule update --init --recursive --depth 1/g' "$TMUX_PLUGIN_MANAGER_PATH/tpm/scripts/update_plugin.sh"
# tmux set-environment -g TMUX_PLUGIN_MANAGER_PATH "$TMUX_PLUGIN_MANAGER_PATH"
# fi
# if [ x"$update_tpm" = x"true" ]; then
# "$TMUX_PLUGIN_MANAGER_PATH/tpm/bin/update_plugins" all >/dev/null 2>&1
# tmux display 'Done updating tpm and plugins...'
# elif [ x"$install_tpm" = x"true" ]; then
# "$TMUX_PLUGIN_MANAGER_PATH/tpm/bin/install_plugins" >/dev/null 2>&1
# tmux display 'Done installing tpm and plugins...'
# fi # fi
# else # else
# tmux display "GitHub doesn't seem to be reachable, skipping installing and/or updating tpm and plugins..." # if curl -Ikfs -o /dev/null --connect-timeout 2 --max-time 2 https://github.com; then
# if [ ! -d "$TMUX_PLUGIN_MANAGER_PATH/tpm" ]; then
# install_tpm=true
# tmux display 'Installing tpm and plugins...'
# git clone --depth 1 https://github.com/tmux-plugins/tpm "$TMUX_PLUGIN_MANAGER_PATH/tpm"
# elif { [ -z "$window_active" ] && _is_enabled "$tmux_conf_update_plugins_on_launch"; } || { [ -n "$window_active" ] && _is_enabled "$tmux_conf_update_plugins_on_reload"; }; then
# update_tpm=true
# tmux display 'Updating tpm and plugins...'
# (cd "$TMUX_PLUGIN_MANAGER_PATH/tpm" && git checkout -q master && git reset -q --hard HEAD && git pull -q origin master)
# fi
# if [ x"$install_tpm" = x"true" ] || [ x"$update_tpm" = x"true" ]; then
# perl -0777 -p -i -e 's/git clone/git clone --depth 1 --shallow-submodules/g
# ;s/(install_plugin "\$plugin")\n(\s+)done/\1&\n\2done\n\2wait/g' "$TMUX_PLUGIN_MANAGER_PATH/tpm/scripts/install_plugins.sh"&
# perl -p -i -e 's/git submodule update --init --recursive/git submodule update --init --recursive --depth 1/g' "$TMUX_PLUGIN_MANAGER_PATH/tpm/scripts/update_plugin.sh"&
# wait
# tmux set-environment -g TMUX_PLUGIN_MANAGER_PATH "$TMUX_PLUGIN_MANAGER_PATH"
# fi
# if [ x"$update_tpm" = x"true" ]; then
# "$TMUX_PLUGIN_MANAGER_PATH/tpm/bin/install_plugins" >/dev/null 2>&1
# "$TMUX_PLUGIN_MANAGER_PATH/tpm/bin/update_plugins" all >/dev/null 2>&1
# "$TMUX_PLUGIN_MANAGER_PATH/tpm/bin/clean_plugins" all >/dev/null 2>&1
# tmux display 'Done updating tpm and plugins...'
# elif [ x"$install_tpm" = x"true" ]; then
# "$TMUX_PLUGIN_MANAGER_PATH/tpm/bin/install_plugins" >/dev/null 2>&1
# tmux display 'Done installing tpm and plugins...'
# fi
# else
# tmux display "GitHub doesn't seem to be reachable, skipping installing and/or updating tpm and plugins..."
# fi
#
# [ -z "$(tmux show -gv '@tpm-install')" ] && tmux set -g '@tpm-install' 'I'
# [ -z "$(tmux show -gv '@tpm-update')" ] && tmux set -g '@tpm-update' 'u'
# [ -z "$(tmux show -gv '@tpm-clean')" ] && tmux set -g '@tpm-clean' 'M-u'
# [ -f "$TMUX_PLUGIN_MANAGER_PATH/tpm/tpm" ] && "$TMUX_PLUGIN_MANAGER_PATH/tpm/tpm"
# tmux set -gu '@tpm-install' \; set -gu '@tpm-update' \; set -gu '@tpm-clean' \; set -gu '@plugin'
# fi # fi
# #
# [ -f "$TMUX_PLUGIN_MANAGER_PATH/tpm/tpm" ] && "$TMUX_PLUGIN_MANAGER_PATH/tpm/tpm"
# if [ -z "$window_active" ] && [ $_tmux_version -lt 240 ]; then # if [ -z "$window_active" ] && [ $_tmux_version -lt 240 ]; then
# tmux run -b "sleep $(expr $(tmux display -p '#{display-time}') / 500) && tmux set display-time 3000 \; display 'This configuration will soon require tmux 2.4+' \; set -u display-time" # tmux run -b "sleep $(expr $(tmux display -p '#{display-time}') / 500) && tmux set display-time 3000 \; display 'This configuration will soon require tmux 2.4+' \; set -u display-time"
# fi # fi
@ -1378,13 +1394,8 @@ run 'cut -c3- ~/.tmux.conf | sh -s _apply_configuration'
# _apply_plugins() { # _apply_plugins() {
# tmux_conf_update_plugins_on_launch=${tmux_conf_update_plugins_on_launch:-true} # tmux_conf_update_plugins_on_launch=${tmux_conf_update_plugins_on_launch:-true}
# tmux_conf_update_plugins_on_reload=${tmux_conf_update_plugins_on_reload:-true} # tmux_conf_update_plugins_on_reload=${tmux_conf_update_plugins_on_reload:-true}
# if [ -n "$(tmux show -gv '@plugin')" ] || [ -n "$(tmux show -gv '@tpm_plugins')" ]; then # tmux_conf_uninstall_plugins_on_reload=${tmux_conf_uninstall_plugins_on_reload:-true}
# tmux run -b "cut -c3- ~/.tmux.conf | sh -s __apply_plugins \"$window_active\" \"$tmux_conf_update_plugins_on_launch\" \"$tmux_conf_update_plugins_on_reload\"" # tmux run -b "cut -c3- ~/.tmux.conf | sh -s __apply_plugins \"$window_active\" \"$tmux_conf_update_plugins_on_launch\" \"$tmux_conf_update_plugins_on_reload\" \"$tmux_conf_uninstall_plugins_on_reload\""
# elif [ -z "$window_active" ]; then
# if [ $_tmux_version -lt 240 ]; then
# tmux run -b 'tmux set display-time 3000 \; display "This configuration will soon require tmux 2.4+" \; set -u display-time'
# fi
# fi
# } # }
# #
# _apply_configuration() { # _apply_configuration() {

View file

@ -367,6 +367,17 @@ tmux_conf_update_plugins_on_launch=true
# - false # - false
tmux_conf_update_plugins_on_reload=true tmux_conf_update_plugins_on_reload=true
# by default, reloading the configuration will uninstall tpm and plugins when no
# plugins are enabled
# - true (default)
# - false
tmux_conf_uninstall_plugins_on_reload=true
# /!\ the tpm bindings differ slightly from upstream:
# - installing plugins: <prefix> + I
# - uninstalling plugins: <prefix> + Alt + u
# - updating plugins: <prefix> + u
# /!\ do not add set -g @plugin 'tmux-plugins/tpm' # /!\ do not add set -g @plugin 'tmux-plugins/tpm'
# /!\ do not add run '~/.tmux/plugins/tpm/tpm' # /!\ do not add run '~/.tmux/plugins/tpm/tpm'

View file

@ -311,6 +311,11 @@ This configuration now comes with built-in [TPM] support:
- `~/.tmux.conf.local` copy ← people who are used to alter - `~/.tmux.conf.local` copy ← people who are used to alter
`.tmux.conf` to add TPM support will have to adapt their configuration `.tmux.conf` to add TPM support will have to adapt their configuration
⚠️ The TPM bindings differ slightly from upstream:
- installing plugins: `<prefix> + I`
- uninstalling plugins: `<prefix> + Alt + u`
- updating plugins: `<prefix> + u`
See `~/.tmux.conf.local` for instructions. See `~/.tmux.conf.local` for instructions.
[TPM]: https://github.com/tmux-plugins/tpm [TPM]: https://github.com/tmux-plugins/tpm