worked around tmux 3.5 not running run-shell commands with /bin/sh anymore, fixes #761
see also tmux/tmux#4143 note this is fixed in tmux 3.5a
This commit is contained in:
parent
5f1047550b
commit
2c9ef1c51b
1 changed files with 39 additions and 32 deletions
71
.tmux.conf
71
.tmux.conf
|
@ -36,7 +36,7 @@ bind e new-window -n "#{TMUX_CONF_LOCAL}" sh -c 'case "${EDITOR:-vim}" in *vim*)
|
|||
%endif
|
||||
|
||||
# reload configuration
|
||||
bind r run '"$TMUX_PROGRAM" ${TMUX_SOCKET:+-S "$TMUX_SOCKET"} source "$TMUX_CONF"' \; display "#{TMUX_CONF} sourced"
|
||||
bind r run "sh -c '\"\$TMUX_PROGRAM\" \${TMUX_SOCKET:+-S \"\$TMUX_SOCKET\"} source \"\$TMUX_CONF\"'" \; display "#{TMUX_CONF} sourced"
|
||||
|
||||
|
||||
# -- display -------------------------------------------------------------------
|
||||
|
@ -144,16 +144,17 @@ bind P choose-buffer # choose which buffer to paste from
|
|||
# -- 8< ------------------------------------------------------------------------
|
||||
|
||||
%if #{==:#{TMUX_PROGRAM},}
|
||||
run 'TMUX_PROGRAM="$(LSOF=$(PATH="$PATH:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" command -v lsof); $LSOF -b -w -a -d txt -p #{pid} -Fn 2>/dev/null | perl -n -e "if (s/^n((?:.(?!dylib$|so$))+)$/\1/g && s/(?:\s+\([^\s]+?\))?$//g) { print; exit } } exit 1; {" || readlink "/proc/#{pid}/exe" 2>/dev/null)"; { [ -f "$TMUX_PROGRAM" ] && [ -x "$TMUX_PROGRAM" ]; } || TMUX_PROGRAM="$(command -v tmux || printf tmux)"; "$TMUX_PROGRAM" -S #{socket_path} set-environment -g TMUX_PROGRAM "$TMUX_PROGRAM"'
|
||||
run "exec sh -c 'TMUX_PROGRAM=\"\$(LSOF=\$(PATH=\"\$PATH:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin\" command -v lsof); \$LSOF -b -w -a -d txt -p #{pid} -Fn 2>/dev/null | perl -n -e \"if (s/^n((?:.(?!dylib\$|so\$))+)\$/\\1/g && s/(?:\s+\\([^\\s]+?\\))?\$//g) { print; exit } } exit 1; {\" || readlink \"/proc/#{pid}/exe\" 2>/dev/null)\"; { [ -f \"\$TMUX_PROGRAM\" ] && [ -x \"\$TMUX_PROGRAM\" ]; } || TMUX_PROGRAM=\"\$(command -v tmux || printf tmux)\"; \"\$TMUX_PROGRAM\" -S #{socket_path} set-environment -g TMUX_PROGRAM \"\$TMUX_PROGRAM\"'"
|
||||
#run 'TMUX_PROGRAM="$(LSOF=$(PATH="$PATH:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" command -v lsof); $LSOF -b -w -a -d txt -p #{pid} -Fn 2>/dev/null | perl -n -e "if (s/^n((?:.(?!dylib$|so$))+)$/\1/g && s/(?:\s+\([^\s]+?\))?$//g) { print; exit } } exit 1; {" || readlink "/proc/#{pid}/exe" 2>/dev/null)"; { [ -f "$TMUX_PROGRAM" ] && [ -x "$TMUX_PROGRAM" ]; } || TMUX_PROGRAM="$(command -v tmux || printf tmux)"; "$TMUX_PROGRAM" -S #{socket_path} set-environment -g TMUX_PROGRAM "$TMUX_PROGRAM"'
|
||||
%endif
|
||||
%if #{==:#{TMUX_SOCKET},}
|
||||
run '"$TMUX_PROGRAM" -S #{socket_path} set-environment -g TMUX_SOCKET "#{socket_path}"'
|
||||
run "exec sh -c '\"\$TMUX_PROGRAM\" -S #{socket_path} set-environment -g TMUX_SOCKET \"#{socket_path}\"'"
|
||||
%endif
|
||||
%if #{==:#{TMUX_CONF},}
|
||||
run '"$TMUX_PROGRAM" set-environment -g TMUX_CONF $(for conf in "$HOME/.tmux.conf" "$XDG_CONFIG_HOME/tmux/tmux.conf" "$HOME/.config/tmux/tmux.conf"; do [ -f "$conf" ] && printf "%s" "$conf" && break; done)'
|
||||
run "exec sh -c '\"\$TMUX_PROGRAM\" set-environment -g TMUX_CONF \$(for conf in \"\$HOME/.tmux.conf\" \"\$XDG_CONFIG_HOME/tmux/tmux.conf\" \"\$HOME/.config/tmux/tmux.conf\"; do [ -f \"\$conf\" ] && printf \"%s\" \"\$conf\" && break; done)'"
|
||||
%endif
|
||||
%if #{==:#{TMUX_CONF_LOCAL},}
|
||||
run '"$TMUX_PROGRAM" set-environment -g TMUX_CONF_LOCAL "$TMUX_CONF.local"'
|
||||
run "exec sh -c '\"\$TMUX_PROGRAM\" set-environment -g TMUX_CONF_LOCAL \"\$TMUX_CONF.local\"'"
|
||||
%endif
|
||||
|
||||
run '"$TMUX_PROGRAM" source "$TMUX_CONF_LOCAL"'
|
||||
|
@ -200,7 +201,7 @@ run 'cut -c3- "$TMUX_CONF" | sh -s _apply_configuration'
|
|||
# }
|
||||
# fi
|
||||
#
|
||||
# _tmux_version=$(tmux -V | awk '{gsub(/[^0-9.]/, "", $2); print ($2+0) * 100}')
|
||||
# _tmux_version=$(tmux -V | perl -n -e '($l, $r) = $_ =~ /^[^0-9]+([0-9.]+)([a-z])?(-rc.*)?$/; print $l * 1000 + ($r eq "" ? 0 : ord($r) - 96)')
|
||||
#
|
||||
# _is_true() {
|
||||
# [ "$1" = "true" ] || [ "$1" = "yes" ] || [ "$1" = "1" ]
|
||||
|
@ -969,7 +970,7 @@ run 'cut -c3- "$TMUX_CONF" | sh -s _apply_configuration'
|
|||
# if ! _is_disabled "$tmux_conf_copy_to_os_clipboard" && _is_true "$tmux_conf_copy_to_os_clipboard"; then
|
||||
# perl -p -i -e "s/(?!.*?$command)\bcopy-(?:selection|pipe)(-end-of-line|-and-cancel|-end-of-line-and-cancel|-no-clear)?\b/copy-pipe\1 '$command'/g" "$cfg"
|
||||
# else
|
||||
# if [ "$_tmux_version" -ge 320 ]; then
|
||||
# if [ "$_tmux_version" -ge 3200 ]; then
|
||||
# perl -p -i -e "s/\bcopy-pipe(-end-of-line|-and-cancel|end-of-line-and-cancel|-no-clear)?\b\s+(\"|')?$command\2?/copy-pipe\1/g" "$cfg"
|
||||
# else
|
||||
# perl -p -i -e "s/\bcopy-pipe(-end-of-line|-and-cancel|end-of-line-and-cancel|-no-clear)?\b\s+(\"|')?$command\2?/copy-selection\1/g" "$cfg"
|
||||
|
@ -1414,7 +1415,7 @@ run 'cut -c3- "$TMUX_CONF" | sh -s _apply_configuration'
|
|||
# tmux_conf_battery_status_charging=$(_decode_unicode_escapes "${tmux_conf_battery_status_charging:-↑}") # U+2191
|
||||
# tmux_conf_battery_status_discharging=$(_decode_unicode_escapes "${tmux_conf_battery_status_discharging:-↓}") # U+2193
|
||||
#
|
||||
# _pkillf "cut -c3- '$TMUX_CONF' \| sh -s _battery"
|
||||
# _pkillf 'sh -s _battery_info'
|
||||
# _battery_info
|
||||
# if [ "$battery_charge" != 0 ]; then
|
||||
# case "$status_left $status_right" in
|
||||
|
@ -1437,14 +1438,16 @@ run 'cut -c3- "$TMUX_CONF" | sh -s _apply_configuration'
|
|||
# -e "s%#\{battery_vbar\}%#(nice cut -c3- '$TMUX_CONF' | sh -s _vbar '$(printf '%s' "$tmux_conf_battery_vbar_palette" | tr ',' ';')' '#{@battery_charge}')%g" \
|
||||
# -e 's%#\{(\?)?battery_status%#\{\1@battery_status%g' \
|
||||
# -e 's%#\{(\?)?battery_percentage%#\{\1@battery_percentage%g')
|
||||
# status_right="#(echo; nice cut -c3- '$TMUX_CONF' | sh -s _battery_status '$tmux_conf_battery_status_charging' '$tmux_conf_battery_status_discharging')$status_right"
|
||||
# status_right="#(nice cut -c3- '$TMUX_CONF' | sh -s _battery_status '$tmux_conf_battery_status_charging' '$tmux_conf_battery_status_discharging')$status_right"
|
||||
# interval=60
|
||||
# if [ "$_tmux_version" -ge 320 ]; then
|
||||
# tmux run -b "trap '[ -n \"\$sleep_pid\" ] && kill -9 \"\$sleep_pid\"; exit 0' TERM; while [ x\"\$('$TMUX_PROGRAM' -S '#{socket_path}' display -p '#{l:#{pid}}')\" = x\"#{pid}\" ]; do nice cut -c3- '$TMUX_CONF' | sh -s _battery_info; sleep $interval & sleep_pid=\$!; wait \"\$sleep_pid\"; sleep_pid=; done"
|
||||
# elif [ "$_tmux_version" -ge 280 ]; then
|
||||
# status_right="#(echo; while [ x\"\$('$TMUX_PROGRAM' -S '#{socket_path}' display -p '#{l:#{pid}}')\" = x\"#{pid}\" ]; do nice cut -c3- '$TMUX_CONF' | sh -s _battery_info; sleep $interval; done)$status_right"
|
||||
# elif [ "$_tmux_version" -gt 240 ]; then
|
||||
# status_right="#(echo; while :; do nice cut -c3- '$TMUX_CONF' | sh -s _battery_info; sleep $interval; done)$status_right"
|
||||
# if [ "$_tmux_version" -eq 3500 ]; then
|
||||
# tmux run -b "exec sh -c 'trap \"[ -n \\\\\"\\\\\$sleep_pid\\\\\" ] && kill -9 \\\\\"\\\\\$sleep_pid\\\\\"; exit 0\" TERM; while [ x\"\$(\"$TMUX_PROGRAM\" -S \"#{socket_path}\" display -p \"#{l:#{pid}}\")\" = x\"#{pid}\" ]; do nice cut -c3- \"$TMUX_CONF\" | sh -s _battery_info; sleep $interval & sleep_pid=\$!; wait \"\$sleep_pid\"; sleep_pid=; done'"
|
||||
# elif [ "$_tmux_version" -ge 3200 ]; then
|
||||
# tmux run -b "trap '[ -n \"\$sleep_pid\" ] && kill -9 \"\$sleep_pid\"; exit 0' TERM; while [ x\"\$(\"$TMUX_PROGRAM\" -S '#{socket_path}' display -p '#{l:#{pid}}')\" = x\"#{pid}\" ]; do nice cut -c3- '$TMUX_CONF' | sh -s _battery_info; sleep $interval & sleep_pid=\$!; wait \"\$sleep_pid\"; sleep_pid=; done"
|
||||
# elif [ "$_tmux_version" -ge 2800 ]; then
|
||||
# status_right="#(while [ x\"\$(\"$TMUX_PROGRAM\" -S '#{socket_path}' display -p '#{l:#{pid}}')\" = x\"#{pid}\" ]; do nice cut -c3- '$TMUX_CONF' | sh -s _battery_info; sleep $interval; done)$status_right"
|
||||
# elif [ "$_tmux_version" -gt 2400 ]; then
|
||||
# status_right="#(while :; do nice cut -c3- '$TMUX_CONF' | sh -s _battery_info; sleep $interval; done)$status_right"
|
||||
# else
|
||||
# status_right="#(nice cut -c3- '$TMUX_CONF' | sh -s _battery_info)$status_right"
|
||||
# fi
|
||||
|
@ -1471,7 +1474,7 @@ run 'cut -c3- "$TMUX_CONF" | sh -s _apply_configuration'
|
|||
# ;;
|
||||
# esac
|
||||
#
|
||||
# _pkillf "cut -c3- '$TMUX_CONF' \| sh -s _uptime"
|
||||
# _pkillf 'sh -s _uptime'
|
||||
# case "$status_left $status_right" in
|
||||
# *'#{uptime_'*|*'#{?uptime_'*)
|
||||
# status_left=$(echo "$status_left" | perl -p -e '
|
||||
|
@ -1494,19 +1497,21 @@ run 'cut -c3- "$TMUX_CONF" | sh -s _apply_configuration'
|
|||
# interval=$(tmux show -gv status-interval)
|
||||
# ;;
|
||||
# esac
|
||||
# if [ "$_tmux_version" -ge 320 ]; then
|
||||
# tmux run -b "trap '[ -n \"\$sleep_pid\" ] && kill -9 \"\$sleep_pid\"; exit 0' TERM; while [ x\"\$('$TMUX_PROGRAM' -S '#{socket_path}' display -p '#{l:#{pid}}')\" = x\"#{pid}\" ]; do nice cut -c3- '$TMUX_CONF' | sh -s _uptime; sleep $interval & sleep_pid=\$!; wait \"\$sleep_pid\"; sleep_pid=; done"
|
||||
# elif [ "$_tmux_version" -ge 280 ]; then
|
||||
# status_right="#(echo; while [ x\"\$('$TMUX_PROGRAM' -S '#{socket_path}' display -p '#{l:#{pid}}')\" = x\"#{pid}\" ]; do nice cut -c3- '$TMUX_CONF' | sh -s _uptime; sleep $interval; done)$status_right"
|
||||
# elif [ "$_tmux_version" -gt 240 ]; then
|
||||
# status_right="#(echo; while :; do nice cut -c3- '$TMUX_CONF' | sh -s _uptime; sleep $interval; done)$status_right"
|
||||
# if [ "$_tmux_version" -eq 3500 ]; then
|
||||
# tmux run -b "exec sh -c 'trap \"[ -n \\\\\"\\\\\$sleep_pid\\\\\" ] && kill -9 \\\\\"\\\\\$sleep_pid\\\\\"; exit 0\" TERM; while [ x\"\$(\"$TMUX_PROGRAM\" -S \"#{socket_path}\" display -p \"#{l:#{pid}}\")\" = x\"#{pid}\" ]; do nice cut -c3- \"$TMUX_CONF\" | sh -s _uptime; sleep $interval & sleep_pid=\$!; wait \"\$sleep_pid\"; sleep_pid=; done'"
|
||||
# elif [ "$_tmux_version" -ge 3200 ]; then
|
||||
# tmux run -b "trap '[ -n \"\$sleep_pid\" ] && kill -9 \"\$sleep_pid\"; exit 0' TERM; while [ x\"\$(\"$TMUX_PROGRAM\" -S '#{socket_path}' display -p '#{l:#{pid}}')\" = x\"#{pid}\" ]; do nice cut -c3- '$TMUX_CONF' | sh -s _uptime; sleep $interval & sleep_pid=\$!; wait \"\$sleep_pid\"; sleep_pid=; done"
|
||||
# elif [ "$_tmux_version" -ge 2800 ]; then
|
||||
# status_right="#(while [ x\"\$(\"$TMUX_PROGRAM\" -S '#{socket_path}' display -p '#{l:#{pid}}')\" = x\"#{pid}\" ]; do nice cut -c3- '$TMUX_CONF' | sh -s _uptime; sleep $interval; done)$status_right"
|
||||
# elif [ "$_tmux_version" -gt 2400 ]; then
|
||||
# status_right="#(while :; do nice cut -c3- '$TMUX_CONF' | sh -s _uptime; sleep $interval; done)$status_right"
|
||||
# else
|
||||
# status_right="#(nice cut -c3- '$TMUX_CONF' | sh -s _uptime)$status_right"
|
||||
# fi
|
||||
# ;;
|
||||
# esac
|
||||
#
|
||||
# _pkillf "cut -c3- '$TMUX_CONF' \| sh -s _loadavg"
|
||||
# _pkillf 'sh -s _loadavg'
|
||||
# case "$status_left $status_right" in
|
||||
# *'#{loadavg'*|*'#{?loadavg'*)
|
||||
# status_left=$(echo "$status_left" | sed -E \
|
||||
|
@ -1514,12 +1519,14 @@ run 'cut -c3- "$TMUX_CONF" | sh -s _apply_configuration'
|
|||
# status_right=$(echo "$status_right" | sed -E \
|
||||
# -e 's/#\{(\?)?loadavg/#\{\1@loadavg/g')
|
||||
# interval=$(tmux show -gv status-interval)
|
||||
# if [ "$_tmux_version" -ge 320 ]; then
|
||||
# tmux run -b "trap '[ -n \"\$sleep_pid\" ] && kill -9 \"\$sleep_pid\"; exit 0' TERM; while [ x\"\$('$TMUX_PROGRAM' -S '#{socket_path}' display -p '#{l:#{pid}}')\" = x\"#{pid}\" ]; do nice cut -c3- '$TMUX_CONF' | sh -s _loadavg; sleep $interval & sleep_pid=\$!; wait \"\$sleep_pid\"; sleep_pid=; done"
|
||||
# elif [ "$_tmux_version" -ge 280 ]; then
|
||||
# status_right="#(echo; while [ x\"\$('$TMUX_PROGRAM' -S '#{socket_path}' display -p '#{l:#{pid}}')\" = x\"#{pid}\" ]; do nice cut -c3- '$TMUX_CONF' | sh -s _loadavg; sleep $interval; done)$status_right"
|
||||
# elif [ "$_tmux_version" -gt 240 ]; then
|
||||
# status_right="#(echo; while :; do nice cut -c3- '$TMUX_CONF' | sh -s _loadavg; sleep $interval; done)$status_right"
|
||||
# if [ "$_tmux_version" -eq 3500 ]; then
|
||||
# tmux run -b "exec sh -c 'trap \"[ -n \\\\\"\\\\\$sleep_pid\\\\\" ] && kill -9 \\\\\"\\\\\$sleep_pid\\\\\"; exit 0\" TERM; while [ x\"\$(\"$TMUX_PROGRAM\" -S \"#{socket_path}\" display -p \"#{l:#{pid}}\")\" = x\"#{pid}\" ]; do nice cut -c3- \"$TMUX_CONF\" | sh -s _loadavg; sleep $interval & sleep_pid=\$!; wait \"\$sleep_pid\"; sleep_pid=; done'"
|
||||
# elif [ "$_tmux_version" -ge 3200 ]; then
|
||||
# tmux run -b "trap '[ -n \"\$sleep_pid\" ] && kill -9 \"\$sleep_pid\"; exit 0' TERM; while [ x\"\$(\"$TMUX_PROGRAM\" -S '#{socket_path}' display -p '#{l:#{pid}}')\" = x\"#{pid}\" ]; do nice cut -c3- '$TMUX_CONF' | sh -s _loadavg; sleep $interval & sleep_pid=\$!; wait \"\$sleep_pid\"; sleep_pid=; done"
|
||||
# elif [ "$_tmux_version" -ge 2800 ]; then
|
||||
# status_right="#(while [ x\"\$(\"$TMUX_PROGRAM\" -S '#{socket_path}' display -p '#{l:#{pid}}')\" = x\"#{pid}\" ]; do nice cut -c3- '$TMUX_CONF' | sh -s _loadavg; sleep $interval; done)$status_right"
|
||||
# elif [ "$_tmux_version" -gt 2400 ]; then
|
||||
# status_right="#(while :; do nice cut -c3- '$TMUX_CONF' | sh -s _loadavg; sleep $interval; done)$status_right"
|
||||
# else
|
||||
# status_right="#(nice cut -c3- '$TMUX_CONF' | sh -s _loadavg)$status_right"
|
||||
# fi
|
||||
|
@ -1564,7 +1571,7 @@ run 'cut -c3- "$TMUX_CONF" | sh -s _apply_configuration'
|
|||
# tmux display 'Done uninstalling tpm and plugins...'
|
||||
# fi
|
||||
# else
|
||||
# if [ "$(command tmux display -p '#{pid} #{version} #{socket_path}')" = "$($TMUX_PROGRAM display -p '#{pid} #{version} #{socket_path}')" ]; then
|
||||
# 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
|
||||
# $(awk '/^[ \t]*set(-option)?.*[ \t]@plugin[ \t]/ { gsub(/'\''/, ""); gsub(/'\"'/, ""); print $NF }' "$TMUX_CONF_LOCAL" 2>/dev/null)
|
||||
|
@ -1637,7 +1644,7 @@ run 'cut -c3- "$TMUX_CONF" | sh -s _apply_configuration'
|
|||
# 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
|
||||
#
|
||||
# if [ "$_tmux_version" -gt 260 ]; then
|
||||
# if [ "$_tmux_version" -gt 2600 ]; then
|
||||
# tmux set -gu '@tpm-install' \; set -gu '@tpm-update' \; set -gu '@tpm-clean' \; set -gu '@plugin' \; set -gu '@tpm_plugins'
|
||||
# else
|
||||
# tmux set -g '@tpm-install' '' \; set -g '@tpm-update' '' \; set -g '@tpm-clean' '' \; set -g '@plugin' '' \; set-gu '@tpm_plugins' ''
|
||||
|
@ -1695,7 +1702,7 @@ run 'cut -c3- "$TMUX_CONF" | sh -s _apply_configuration'
|
|||
# tmux run -b 'tmux set display-time 3000 \; display "This configuration requires awk" \; set -u display-time \; run "sleep 3" \; kill-server'
|
||||
# return
|
||||
# fi
|
||||
# if [ "$_tmux_version" -lt 260 ]; then
|
||||
# if [ "$_tmux_version" -lt 2600 ]; then
|
||||
# tmux run -b 'tmux set display-time 3000 \; display "This configuration requires tmux 2.6+" \; set -u display-time \; run "sleep 3" \; kill-server'
|
||||
# return
|
||||
# fi
|
||||
|
|
Loading…
Reference in a new issue