From 0da7d5c3db463a048b654bac79321d532a890271 Mon Sep 17 00:00:00 2001 From: Gregory Pakosz Date: Sun, 31 Oct 2021 18:15:18 +0100 Subject: [PATCH] reworked pane / tty introspection (2) fixed implementation and calls to _root() --- .tmux.conf | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/.tmux.conf b/.tmux.conf index 39214b3..6c49bba 100644 --- a/.tmux.conf +++ b/.tmux.conf @@ -497,10 +497,10 @@ run 'cut -c3- ~/.tmux.conf | sh -s _apply_configuration' # # _pane_info() { # pane_pid="$1" -# tty="${2##/dev/}" +# pane_tty="${2##/dev/}" # case "$_uname_s" in # *CYGWIN*) -# ps -al | tail -n +2 | awk -v pane_pid="$pane_pid" -v tty="$tty" ' +# ps -al | tail -n +2 | awk -v pane_pid="$pane_pid" -v tty="$pane_tty" ' # ((/ssh/ && !/-W/) || !/ssh/) && $5 == tty { # user[$1] = $6; parent[$1] = $2; child[$2] = $1 # } @@ -518,7 +518,7 @@ run 'cut -c3- ~/.tmux.conf | sh -s _apply_configuration' # ' # ;; # *) -# ps -t "$tty" -o user=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -o pid= -o ppid= -o command= | awk -v pane_pid="$pane_pid" ' +# ps -t "$pane_tty" -o user=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -o pid= -o ppid= -o command= | awk -v pane_pid="$pane_pid" ' # NR > 1 && ((/ssh/ && !/-W/) || !/ssh/) { # user[$2] = $1; parent[$2] = $3; child[$3] = $2; pid=$2; $1 = $2 = $3 = ""; command[pid] = substr($0,4) # } @@ -549,10 +549,10 @@ run 'cut -c3- ~/.tmux.conf | sh -s _apply_configuration' # # _username() { # pane_pid=${1:-$(tmux display -p '#{pane_pid}')} -# tty=${2:-$(tmux display -p '#{s,/dev/,,:pane_tty}')} +# pane_tty=${2:-$(tmux display -p '#{s,/dev/,,:pane_tty}')} # ssh_only=$3 # -# pane_info=$(_pane_info "$pane_pid" "$tty") +# pane_info=$(_pane_info "$pane_pid" "$pane_tty") # command=${pane_info#*:} # command=${command#*:} # @@ -574,12 +574,12 @@ run 'cut -c3- ~/.tmux.conf | sh -s _apply_configuration' # # _hostname() { # pane_pid=${1:-$(tmux display -p '#{pane_pid}')} -# tty=${2:-$(tmux display -p '#{s,/dev/,,:pane_tty}')} +# pane_tty=${2:-$(tmux display -p '#{s,/dev/,,:pane_tty}')} # ssh_only=$3 # full=$4 # h_or_H=$5 # -# pane_info=$(_pane_info "$pane_pid" "$tty") +# pane_info=$(_pane_info "$pane_pid" "$pane_tty") # command=${pane_info#*:} # command=${command#*:} # @@ -610,10 +610,11 @@ run 'cut -c3- ~/.tmux.conf | sh -s _apply_configuration' # } # # _root() { -# tty=${1:-$(tmux display -p '#{s,/dev/,,:pane_tty}')} -# root=$2 +# pane_pid=${1:-$(tmux display -p '#{pane_pid}')} +# pane_tty=${2:-$(tmux display -p '#{s,/dev/,,:pane_tty}')} +# root=$3 # -# username=$(_username "$tty" false) +# username=$(_username "$pane_id" "$pane_tty" false) # # [ x"$username" = x"root" ] && echo "$root" # } @@ -668,10 +669,10 @@ run 'cut -c3- ~/.tmux.conf | sh -s _apply_configuration' # # _split_window_ssh() { # pane_pid=${1:-$(tmux display -p '#{pane_pid}')} -# tty=${2:-$(tmux display -p '#{s,/dev/,,:pane_tty}')} +# pane_tty=${2:-$(tmux display -p '#{s,/dev/,,:pane_tty}')} # shift # -# pane_info=$(_pane_info "$pane_pid" "$tty") +# pane_info=$(_pane_info "$pane_pid" "$pane_tty") # command=${pane_info#*:} # command=${command#*:} # @@ -1030,7 +1031,7 @@ run 'cut -c3- ~/.tmux.conf | sh -s _apply_configuration' # -e "s%#{root}%#[fg=$tmux_conf_theme_root_fg]#[bg=$tmux_conf_theme_root_bg]#[$tmux_conf_theme_root_attr]#{?#{==:#(cut -c3- ~/.tmux.conf | sh -s _username #{pane_pid} #{s,/dev/,,:pane_tty} #D),root},$tmux_conf_theme_root,}#[inherit]%g") # else # status_left=$(echo "$status_left" | sed \ -# -e "s%#{root}%#[fg=$tmux_conf_theme_root_fg]#[bg=$tmux_conf_theme_root_bg]#[$tmux_conf_theme_root_attr]#(cut -c3- ~/.tmux.conf | sh -s _root #{s,/dev/,,:pane_tty} $tmux_conf_theme_root #D)#[inherit]%g") +# -e "s%#{root}%#[fg=$tmux_conf_theme_root_fg]#[bg=$tmux_conf_theme_root_bg]#[$tmux_conf_theme_root_attr]#(cut -c3- ~/.tmux.conf | sh -s _root #{pane_pid} #{s,/dev/,,:pane_tty} $tmux_conf_theme_root #D)#[inherit]%g") # fi # # status_left=$(printf '%s' "$status_left" | awk \ @@ -1113,12 +1114,12 @@ run 'cut -c3- ~/.tmux.conf | sh -s _apply_configuration' # -e "s%#{synchronized}%#[fg=$tmux_conf_theme_synchronized_fg]#[bg=$tmux_conf_theme_synchronized_bg]#[$tmux_conf_theme_synchronized_attr]#{?pane_synchronized,$tmux_conf_theme_synchronized ,}%g" \ # -e 's%#{circled_session_name}%#(cut -c3- ~/.tmux.conf | sh -s _circled #S)%g') # -# if [ -n "$(tmux display -p '#{version}')" ]; then +# if [ -z "$(tmux display -p '#{version}')" ]; then # status_right=$(echo "$status_right" | sed \ # -e "s%#{root}%#[fg=$tmux_conf_theme_root_fg]#[bg=$tmux_conf_theme_root_bg]#[$tmux_conf_theme_root_attr]#{?#{==:#(cut -c3- ~/.tmux.conf | sh -s _username #{pane_pid} #{s,/dev/,,:pane_tty} #D),root},$tmux_conf_theme_root,}#[inherit]%g") # else # status_right=$(echo "$status_right" | sed \ -# -e "s%#{root}%#[fg=$tmux_conf_theme_root_fg]#[bg=$tmux_conf_theme_root_bg]#[$tmux_conf_theme_root_attr]#(cut -c3- ~/.tmux.conf | sh -s _root #{s,/dev/,,:pane_tty} $tmux_conf_theme_root #D)#[inherit]%g") +# -e "s%#{root}%#[fg=$tmux_conf_theme_root_fg]#[bg=$tmux_conf_theme_root_bg]#[$tmux_conf_theme_root_attr]#(cut -c3- ~/.tmux.conf | sh -s _root #{pane_pid} #{s,/dev/,,:pane_tty} $tmux_conf_theme_root #D)#[inherit]%g") # fi # # status_right=$(printf '%s' "$status_right" | awk \