From a63dc5c6a9a59a935c058fba12009495ef0c4100 Mon Sep 17 00:00:00 2001 From: Gregory Pakosz Date: Sun, 29 Aug 2021 11:02:08 +0200 Subject: [PATCH] check connectivity to github.com before installing and/or updating tpm and plugins, fixes #513 --- .tmux.conf | 50 +++++++++++++++++++++++++++--------------------- .tmux.conf.local | 1 + 2 files changed, 29 insertions(+), 22 deletions(-) diff --git a/.tmux.conf b/.tmux.conf index 8e7b05a..18df782 100644 --- a/.tmux.conf +++ b/.tmux.conf @@ -1341,29 +1341,35 @@ run 'cut -c3- ~/.tmux.conf | sh -s _apply_configuration' # tmux_conf_update_plugins_on_reload="$3" # # TMUX_PLUGIN_MANAGER_PATH=${TMUX_PLUGIN_MANAGER_PATH:-~/.tmux/plugins} -# 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) +# +# 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 --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 +# else +# tmux display "GitHub doesn't seem to be reachable, skipping installing and/or updating tpm and plugins..." # 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 -# "$TMUX_PLUGIN_MANAGER_PATH/tpm/tpm" +# +# [ -f "$TMUX_PLUGIN_MANAGER_PATH/tpm/tpm" ] && "$TMUX_PLUGIN_MANAGER_PATH/tpm/tpm" # 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" # fi diff --git a/.tmux.conf.local b/.tmux.conf.local index 057b2b2..c440076 100644 --- a/.tmux.conf.local +++ b/.tmux.conf.local @@ -347,6 +347,7 @@ tmux_conf_copy_to_os_clipboard=false # move status line to top #set -g status-position top + # -- tpm ----------------------------------------------------------------------- # while I don't use tpm myself, many people requested official support so here