From fc4e3bc37b80adc8f9f1807419b44c25e4efa195 Mon Sep 17 00:00:00 2001 From: Gregory Pakosz Date: Wed, 31 Jan 2024 14:27:24 +0100 Subject: [PATCH] launch tpm early if it's already present on the filesystem, resolves #713 --- .tmux.conf | 48 ++++++++++++++++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 14 deletions(-) diff --git a/.tmux.conf b/.tmux.conf index ab848b3..7818061 100644 --- a/.tmux.conf +++ b/.tmux.conf @@ -1542,12 +1542,20 @@ run 'cut -c3- "$TMUX_CONF" | sh -s _apply_configuration' # else # if [ "$(command tmux display -p '#{pid} #{version} #{socket_path}')" = "$($TMUX_PROGRAM display -p '#{pid} #{version} #{socket_path}')" ]; then # tpm_plugins=$(cat << EOF | tr ' ' '\n' | awk '/^\s*$/ {next;}; !seen[$0]++ { gsub(/^[ \t]+/,"",$0); gsub(/[ \t]+$/,"",$0); print $0 }' -# "$tpm_plugins" +# $tpm_plugins # $(awk '/^[ \t]*set(-option)?.*[ \t]@plugin[ \t]/ { gsub(/'\''/, ""); gsub(/'\"'/, ""); print $NF }' "$TMUX_CONF_LOCAL" 2>/dev/null) # EOF # ) # tmux set-environment -g TMUX_PLUGIN_MANAGER_PATH "$TMUX_PLUGIN_MANAGER_PATH" # tmux set -g '@tpm_plugins' "$tpm_plugins" +# +# if [ -d "$TMUX_PLUGIN_MANAGER_PATH/tpm" ]; then +# [ -z "$(tmux show -gqv '@tpm-install')" ] && tmux set -g '@tpm-install' 'I' +# [ -z "$(tmux show -gqv '@tpm-update')" ] && tmux set -g '@tpm-update' 'u' +# [ -z "$(tmux show -gqv '@tpm-clean')" ] && tmux set -g '@tpm-clean' 'M-u' +# "$TMUX_PLUGIN_MANAGER_PATH/tpm/tpm" || tmux display "One or more tpm plugin(s) failed" +# fi +# # if git ls-remote -hq https://github.com/gpakosz/.tmux.git master > /dev/null; then # if [ ! -d "$TMUX_PLUGIN_MANAGER_PATH/tpm" ]; then # install_tpm=true @@ -1566,29 +1574,41 @@ run 'cut -c3- "$TMUX_CONF" | sh -s _apply_configuration' # fi # if [ "$update_tpm" = "true" ]; then # { -# echo "Invoking $TMUX_PLUGIN_MANAGER_PATH/tpm/bin/install_plugins ..." > "$TMUX_PLUGIN_MANAGER_PATH/tpm_log.txt" 2>&1 && \ -# "$TMUX_PLUGIN_MANAGER_PATH/tpm/bin/install_plugins" >> "$TMUX_PLUGIN_MANAGER_PATH/tpm_log.txt" 2>&1 &&\ -# echo "Invoking $TMUX_PLUGIN_MANAGER_PATH/tpm/bin/update_plugins all ..." > "$TMUX_PLUGIN_MANAGER_PATH/tpm_log.txt" 2>&1 && \ -# "$TMUX_PLUGIN_MANAGER_PATH/tpm/bin/update_plugins" all >> "$TMUX_PLUGIN_MANAGER_PATH/tpm_log.txt" 2>&1 &&\ -# echo "Invoking $TMUX_PLUGIN_MANAGER_PATH/tpm/bin/clean_plugins all ..." > "$TMUX_PLUGIN_MANAGER_PATH/tpm_log.txt" 2>&1 && \ -# "$TMUX_PLUGIN_MANAGER_PATH/tpm/bin/clean_plugins" all >> "$TMUX_PLUGIN_MANAGER_PATH/tpm_log.txt" 2>&1 &&\ +# { +# printf 'List of discovered tpm plugins: %s\n' "$(printf '%s\n' "$tpm_plugins" | paste -s -d ' ' -)" | perl -MPOSIX=strftime -MTime::HiRes=gettimeofday -pe 'my ($s, $us) = gettimeofday(); printf ("[%s.%03d]\t ", strftime("%Y-%m-%d %H:%M:%S", localtime $s), $us / 1000)' +# printf '%s\n' "Invoking $TMUX_PLUGIN_MANAGER_PATH/tpm/bin/install_plugins" | perl -MPOSIX=strftime -MTime::HiRes=gettimeofday -pe 'my ($s, $us) = gettimeofday(); printf ("[%s.%03d]\t ", strftime("%Y-%m-%d %H:%M:%S", localtime $s), $us / 1000)' +# "$TMUX_PLUGIN_MANAGER_PATH/tpm/bin/install_plugins" 2>&1 | perl -MPOSIX=strftime -MTime::HiRes=gettimeofday -pe 'my ($s, $us) = gettimeofday(); printf ("[%s.%03d]\t ", strftime("%Y-%m-%d %H:%M:%S", localtime $s), $us / 1000)' +# printf '%s\n' "Invoking $TMUX_PLUGIN_MANAGER_PATH/tpm/bin/update_plugins all" | perl -MPOSIX=strftime -MTime::HiRes=gettimeofday -pe 'my ($s, $us) = gettimeofday(); printf ("[%s.%03d]\t ", strftime("%Y-%m-%d %H:%M:%S", localtime $s), $us / 1000)' +# "$TMUX_PLUGIN_MANAGER_PATH/tpm/bin/update_plugins" all 2>&1 | perl -MPOSIX=strftime -MTime::HiRes=gettimeofday -pe 'my ($s, $us) = gettimeofday(); printf ("[%s.%03d]\t ", strftime("%Y-%m-%d %H:%M:%S", localtime $s), $us / 1000)' +# printf '%s\n' "Invoking $TMUX_PLUGIN_MANAGER_PATH/tpm/bin/clean_plugins all" | perl -MPOSIX=strftime -MTime::HiRes=gettimeofday -pe 'my ($s, $us) = gettimeofday(); printf ("[%s.%03d]\t ", strftime("%Y-%m-%d %H:%M:%S", localtime $s), $us / 1000)' +# "$TMUX_PLUGIN_MANAGER_PATH/tpm/bin/clean_plugins" all 2>&1 | perl -MPOSIX=strftime -MTime::HiRes=gettimeofday -pe 'my ($s, $us) = gettimeofday(); printf ("[%s.%03d]\t ", strftime("%Y-%m-%d %H:%M:%S", localtime $s), $us / 1000)' +# printf 'Done.\n' | perl -MPOSIX=strftime -MTime::HiRes=gettimeofday -pe 'my ($s, $us) = gettimeofday(); printf ("[%s.%03d]\t ", strftime("%Y-%m-%d %H:%M:%S", localtime $s), $us / 1000)' +# printf '\n' +# } >> "$TMUX_PLUGIN_MANAGER_PATH/tpm_log.txt" +# # tmux display 'Done updating tpm and plugins...' # } || tmux display 'Failed updating tpm and plugins...' # elif [ "$install_tpm" = "true" ]; then # { -# echo "Invoking $TMUX_PLUGIN_MANAGER_PATH/tpm/bin/install_plugins ..." > "$TMUX_PLUGIN_MANAGER_PATH/tpm_log.txt" 2>&1 && \ -# "$TMUX_PLUGIN_MANAGER_PATH/tpm/bin/install_plugins" >> "$TMUX_PLUGIN_MANAGER_PATH/tpm_log.txt" 2>&1 +# { +# printf 'List of discovered tpm plugins: %s\n' "$(printf '%s\n' "$tpm_plugins" | paste -s -d ' ' -)" | perl -MPOSIX=strftime -MTime::HiRes=gettimeofday -pe 'my ($s, $us) = gettimeofday(); printf ("[%s.%03d]\t ", strftime("%Y-%m-%d %H:%M:%S", localtime $s), $us / 1000)' +# printf '%s\n' "Invoking $TMUX_PLUGIN_MANAGER_PATH/tpm/bin/install_plugins" | perl -MPOSIX=strftime -MTime::HiRes=gettimeofday -pe 'my ($s, $us) = gettimeofday(); printf ("[%s.%03d]\t ", strftime("%Y-%m-%d %H:%M:%S", localtime $s), $us / 1000)' +# "$TMUX_PLUGIN_MANAGER_PATH/tpm/bin/install_plugins" 2>&1 | perl -MPOSIX=strftime -MTime::HiRes=gettimeofday -pe 'my ($s, $us) = gettimeofday(); printf ("[%s.%03d]\t ", strftime("%Y-%m-%d %H:%M:%S", localtime $s), $us / 1000)' +# printf 'Done.\n' | perl -MPOSIX=strftime -MTime::HiRes=gettimeofday -pe 'my ($s, $us) = gettimeofday(); printf ("[%s.%03d]\t ", strftime("%Y-%m-%d %H:%M:%S", localtime $s), $us / 1000)' +# printf '\n' >> "$TMUX_PLUGIN_MANAGER_PATH/tpm_log.txt" +# } >> "$TMUX_PLUGIN_MANAGER_PATH/tpm_log.txt" +# # tmux display 'Done installing tpm and plugins...' +# +# [ -z "$(tmux show -gqv '@tpm-install')" ] && tmux set -g '@tpm-install' 'I' +# [ -z "$(tmux show -gqv '@tpm-update')" ] && tmux set -g '@tpm-update' 'u' +# [ -z "$(tmux show -gqv '@tpm-clean')" ] && tmux set -g '@tpm-clean' 'M-u' +# "$TMUX_PLUGIN_MANAGER_PATH/tpm/tpm" || tmux display "One or more tpm plugin(s) failed" # } || tmux display 'Failed 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 -gqv '@tpm-install')" ] && tmux set -g '@tpm-install' 'I' -# [ -z "$(tmux show -gqv '@tpm-update')" ] && tmux set -g '@tpm-update' 'u' -# [ -z "$(tmux show -gqv '@tpm-clean')" ] && tmux set -g '@tpm-clean' 'M-u' -# "$TMUX_PLUGIN_MANAGER_PATH/tpm/tpm" || tmux display "One or more tpm plugin(s) failed" # else # tmux run -b "sleep \$((#{display-time} / 1000)) && '$TMUX_PROGRAM' set display-time 3000 \; display 'Cannot use tpm which assumes a globally installed tmux' \; set -u display-time" # fi