1
0
Fork 0
mirror of synced 2024-11-18 07:25:34 -05:00

fixed #{username} being truncated under Cygwin

This commit is contained in:
Gregory Pakosz 2020-04-26 15:56:48 +02:00
parent 74602e8d8d
commit 7a64679c2d

View file

@ -501,14 +501,9 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim
# tty="${1##/dev/}" # tty="${1##/dev/}"
# case "$_uname_s" in # case "$_uname_s" in
# *CYGWIN*) # *CYGWIN*)
# cygwin=true # ps -al | tail -n +2 | awk -v tty="$tty" '
# ;; # ((/ssh/ && !/-W/) || !/ssh/) && $5 == tty {
# esac # user[$1] = $6; parent[$1] = $2; child[$2] = $1
#
# if [ x"$cygwin" = x"true" ]; then
# ps -af | tail -n +2 | awk -v tty="$tty" '
# ((/ssh/ && !/-W/) || !/ssh/) && $4 == tty {
# user[$2] = $1; parent[$2] = $3; child[$3] = $2
# } # }
# END { # END {
# for (i in parent) # for (i in parent)
@ -521,16 +516,18 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim
# { # {
# file = "/proc/" i "/cmdline"; getline command < file; close(file) # file = "/proc/" i "/cmdline"; getline command < file; close(file)
# gsub(/\0/, " ", command) # gsub(/\0/, " ", command)
# print i, user[i], command # "id -un " user[i] | getline username
# print i":"username":"command
# exit # exit
# } # }
# } # }
# } # }
# ' # '
# else # ;;
# *)
# ps -t "$tty" -o user=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -o pid= -o ppid= -o command= | awk ' # ps -t "$tty" -o user=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -o pid= -o ppid= -o command= | awk '
# NR > 1 && ((/ssh/ && !/-W/) || !/ssh/) { # NR > 1 && ((/ssh/ && !/-W/) || !/ssh/) {
# user[$2] = $1; parent[$2] = $3; child[$3] = $2; pid=$2; $1 = $2 = $3 = ""; command[pid] = $0 # user[$2] = $1; parent[$2] = $3; child[$3] = $2; pid=$2; $1 = $2 = $3 = ""; command[pid] = substr($0,4)
# } # }
# END { # END {
# for (i in parent) # for (i in parent)
@ -541,19 +538,20 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim
# #
# if (!(i in child) && j != 1) # if (!(i in child) && j != 1)
# { # {
# print i, user[i], command[i] # print i":"user[i]":"command[i]
# exit # exit
# } # }
# } # }
# } # }
# ' # '
# fi # ;;
# esac
# } # }
# #
# _ssh_or_mosh_args() { # _ssh_or_mosh_args() {
# case "$1" in # case "$1" in
# *ssh*) # *ssh*)
# args=$(printf '%s' "$1" | awk '/ssh/ && !/vagrant ssh/ && !/autossh/ && !/-W/ { $1 = $2 = $3 = ""; print $0; exit }') # args=$(printf '%s' "$1" | awk '/ssh/ && !/vagrant ssh/ && !/autossh/ && !/-W/ { $1 = ""; print $0; exit }')
# ;; # ;;
# *mosh-client*) # *mosh-client*)
# args=$(printf '%s' "$1" | sed -E -e 's/.*mosh-client -# (.*)\|.*$/\1/' -e 's/-[^ ]*//g' -e 's/\d:\d//g') # args=$(printf '%s' "$1" | sed -E -e 's/.*mosh-client -# (.*)\|.*$/\1/' -e 's/-[^ ]*//g' -e 's/\d:\d//g')
@ -568,8 +566,10 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim
# ssh_only=$2 # ssh_only=$2
# #
# tty_info=$(_tty_info "$tty") # tty_info=$(_tty_info "$tty")
# command=${tty_info#*:}
# command=${command#*:}
# #
# ssh_or_mosh_args=$(_ssh_or_mosh_args "$tty_info") # ssh_or_mosh_args=$(_ssh_or_mosh_args "$command")
# if [ -n "$ssh_or_mosh_args" ]; then # if [ -n "$ssh_or_mosh_args" ]; then
# # shellcheck disable=SC2086 # # shellcheck disable=SC2086
# username=$(ssh -G $ssh_or_mosh_args 2>/dev/null | awk '/^user / { print $2; exit }') # username=$(ssh -G $ssh_or_mosh_args 2>/dev/null | awk '/^user / { print $2; exit }')
@ -577,8 +577,8 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim
# [ -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 -T -o ControlPath=none -o ProxyCommand="sh -c 'echo %%username%% %r >&2'" $ssh_or_mosh_args 2>&1 | awk '/^%username% / { print $2; exit }')
# else # else
# if ! _is_enabled "$ssh_only"; then # if ! _is_enabled "$ssh_only"; then
# username="${tty_info#* }" # username=${tty_info#*:}
# username="${username%% *}" # username=${username%%:*}
# fi # fi
# fi # fi
# #
@ -590,8 +590,10 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim
# ssh_only=$2 # ssh_only=$2
# #
# tty_info=$(_tty_info "$tty") # tty_info=$(_tty_info "$tty")
# command=${tty_info#*:}
# command=${command#*:}
# #
# ssh_or_mosh_args=$(_ssh_or_mosh_args "$tty_info") # ssh_or_mosh_args=$(_ssh_or_mosh_args "$command")
# if [ -n "$ssh_or_mosh_args" ]; then # if [ -n "$ssh_or_mosh_args" ]; then
# # shellcheck disable=SC2086 # # shellcheck disable=SC2086
# hostname=$(ssh -G $ssh_or_mosh_args 2>/dev/null | awk '/^hostname / { print $2; exit }') # hostname=$(ssh -G $ssh_or_mosh_args 2>/dev/null | awk '/^hostname / { print $2; exit }')
@ -677,7 +679,8 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim
# shift # shift
# #
# tty_info=$(_tty_info "$tty") # tty_info=$(_tty_info "$tty")
# command=$(printf '%s' "$tty_info" | cut -d' ' -f3-) # command=${tty_info#*:}
# command=${command#*:}
# #
# case "$command" in # case "$command" in
# *mosh-client*) # *mosh-client*)