diff --git a/.tmux.conf b/.tmux.conf index 3e3bdca..62447e5 100644 --- a/.tmux.conf +++ b/.tmux.conf @@ -501,8 +501,8 @@ run 'cut -c3- ~/.tmux.conf | sh -s _apply_configuration' # case "$_uname_s" in # *CYGWIN*) # 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 +# ((/ssh/ && !/-W/) || !/ssh/) && !/tee/ && $5 == tty { +# user[$1] = $6; if (!child[$2]) child[$2] = $1 # } # END { # pid = pane_pid @@ -516,10 +516,24 @@ run 'cut -c3- ~/.tmux.conf | sh -s _apply_configuration' # } # ' # ;; +# *Linux*) +# ps -t "$pane_tty" --sort=lstart -o user=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -o pid= -o ppid= -o command= | awk -v pane_pid="$pane_pid" ' +# ((/ssh/ && !/-W/) || !/ssh/) && !/tee/ { +# user[$2] = $1; if (!child[$3]) child[$3] = $2; pid=$2; $1 = $2 = $3 = ""; command[pid] = substr($0,4) +# } +# END { +# pid = pane_pid +# while (child[pid]) +# pid = child[pid] +# +# print pid":"user[pid]":"command[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) +# ((/ssh/ && !/-W/) || !/ssh/) && !/tee/ { +# user[$2] = $1; if (!child[$3]) child[$3] = $2; pid=$2; $1 = $2 = $3 = ""; command[pid] = substr($0,4) # } # END { # pid = pane_pid @@ -536,7 +550,7 @@ run 'cut -c3- ~/.tmux.conf | sh -s _apply_configuration' # _ssh_or_mosh_args() { # case "$1" in # *ssh*) -# args=$(printf '%s' "$1" | perl -n -e 'print if s/(.*?)\bssh\b\s+(.*)/\2/') +# args=$(printf '%s' "$1" | perl -n -e 'print if s/.*?\bssh[\w]*\s*((?:\s+-\w+)*)(\s+\w+)(\s\w+)?/\1\2/') # ;; # *mosh-client*) # args=$(printf '%s' "$1" | sed -E -e 's/.*mosh-client -# (.*)\|.*$/\1/' -e 's/-[^ ]*//g' -e 's/\d:\d//g') @@ -560,7 +574,8 @@ run 'cut -c3- ~/.tmux.conf | sh -s _apply_configuration' # # shellcheck disable=SC2086 # username=$(ssh -G $ssh_or_mosh_args 2>/dev/null | awk '/^user / { print $2; exit }') # # shellcheck disable=SC2086 -# [ -z "$username" ] && username=$(ssh -T -o ControlPath=none -o ProxyCommand="sh -c 'echo %%username%% %r >&2'" $ssh_or_mosh_args 2>&1 | awk '/^%username% / { print $2; exit }') +# [ -z "$username" ] && username=$(ssh $ssh_or_mosh_args -T -o ControlPath=none -o ProxyCommand="sh -c 'echo %%username%% %r >&2'" 2>&1 | awk '/^%username% / { print $2; exit }') +# [ -z "$username" ] && username=$(ssh $ssh_or_mosh_args -v -T -o ControlPath=none -o ProxyCommand=false -o IdentityFile='%%username%%/%r' 2>&1 | awk '/%username%/ { print substr($4,12); exit }') # else # if ! _is_enabled "$ssh_only"; then # username=${pane_info#*:}