Closed TheZenTester closed 1 year ago
Hello @TheZenTester,
All you need is #{hostname}
Can you please, set tmux_conf_theme_status_right
to only an try it?
tmux_conf_theme_status_right='#{hostname}'
Apologies, I forgot to mention that solution doesn't work. When just set to #{hostname}
, the status bar is blank. Even when following your instructions to set tmux_conf_theme_status_right='#{hostname}'
Ok then let's try to troubleshoot this
What's your OS?
Then set tmux_conf_theme_status_right
to #{hostname}
tmux_conf_theme_status_right='#{hostname}'
Reload the configuration
From there, open a new pane and run
$ tmux display -p '#{pane_pid} #{b:pane_tty} false false #h #D'
25144 ttys007 false false MBP2018 %18
Then from this pane, ssh into jumpbox
Then open another pane and run
$ cut -c3- ~/.tmux.conf | sh -sx _hostname 25144 ttys007 false false MBP2018 %18
And paste the output in a comment.
Of course, you need to adapt 25144
, ttys007
, MBP2018
, %18
with the values you got from step 4
I appreciate the help!
Linux localsystem 5.14.0-1056-oem #63-Ubuntu SMP Fri Dec 16 14:32:59 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Output from step 6:❯ cut -c3- ~/.tmux.conf | sh -sx _hostname 2023933 11 false false localsystem %51 ─╯
+ :
+ set -e
+ unset GREP_OPTIONS
+ export LC_NUMERIC=C
+ set +H
+ true
+ printf
+ sed -E s///
+ uname -s
+ _uname_s=Linux
+ tmux -V
+ awk {gsub(/[^0-9.]/, "", $2); print ($2+0) * 100}
+ _tmux_version=300
+ command -v pkill
+ _hostname 2023933 11 false false localsystem %51
+ pane_pid=2023933
+ pane_tty=11
+ ssh_only=false
+ full=false
+ h_or_H=localsystem
+ _pane_info 2023933 11
+ pane_pid=2023933
+ pane_tty=11
+ ps -t 11 --sort=lstart -o user=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -o pid= -o ppid= -o command=
+ awk -v pane_pid=2023933
((/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]
}
+ pane_info=2025223:zentester:ps -t 11 --sort=lstart -o user=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -o pid= -o ppid= -o command=
+ command=zentester:ps -t 11 --sort=lstart -o user=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -o pid= -o ppid= -o command=
+ command=ps -t 11 --sort=lstart -o user=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -o pid= -o ppid= -o command=
+ _ssh_or_mosh_args ps -t 11 --sort=lstart -o user=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -o pid= -o ppid= -o command=
+ printf %s
+ ssh_or_mosh_args=
+ [ -n ]
+ _is_true false
+ [ xfalse = xtrue ]
+ [ xfalse = xyes ]
+ [ xfalse = x1 ]
+ hostname=localsystem
+ printf %s\n localsystem
localsystem
Something is making SSH introspection fail.
I find ps -t 11 --sort=lstart -o user=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -o pid= -o ppid= -o command=
suspicious.
Are you sure the TTY is named "just" 11
?
What if you run
$ tmux display -p '#{pane_tty}'
Original command & output from step 4 in your original troubleshooting instructions
❯ tmux display -p '#{pane_pid} #{b:pane_tty} false false #h #D' ─╯
2023933 11 false false localsystem %51
Output from tmux display:
❯ tmux display -p '#{pane_tty}' ─╯
/dev/pts/11
Ok can you please paste the output of the following command then
$ ps -t 11 --sort=lstart -o user=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -o pid= -o ppid= -o command=
Assuming the pane bound to /dev/pts/11
still contains an ssh process to jumpbox
, otherwise update accordingly
There should be a pane that's running an ssh connection: let's assume it's /dev/pts/11
And another pane from which to launch the ps -t 11 --sort=lstart -o user=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -o pid= -o ppid= -o command=
❯ ps -t 11 --sort=lstart -o user=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -o pid= -o ppid= -o command= ─╯
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
zentester 2023933 3738 -zsh
zentester 2023995 3179 -zsh
zentester 2024104 3179 -zsh
zentester 2024106 3179 -zsh
zentester 2024107 2023995 /home/zentester/.cache/gitstatus/gitstatusd-linux-x86_64 -G v1.5.4 -s -1 -u -1 -d -1 -c -1
zentester 2066762 2023933 ps -t 11 --sort=lstart -o user=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -o pid= -o ppid= -o command=
I have an ssh connection open within a different window of the same pane of which i'm running the ps
command locally, and in a separate pane i have an ssh connection as well
As you can see, there's no ssh process associated with that TTY
Dammit I messed the instructions 😞 sorry
I edited the instructions above, so that people don't try to debug with them
Attempted again with updated instructions, output below:
❯ cut -c3- ~/.tmux.conf | sh -sx _hostname 2068966 11 false false localsystem %56 ─╯
+ :
+ set -e
+ unset GREP_OPTIONS
+ export LC_NUMERIC=C
+ set +H
+ true
+ printf
+ sed -E s///
+ uname -s
+ _uname_s=Linux
+ tmux -V
+ awk {gsub(/[^0-9.]/, "", $2); print ($2+0) * 100}
+ _tmux_version=300
+ command -v pkill
+ _hostname 2068966 11 false false localsystem %56
+ pane_pid=2068966
+ pane_tty=11
+ ssh_only=false
+ full=false
+ h_or_H=localsystem
+ _pane_info 2068966 11
+ pane_pid=2068966
+ pane_tty=11
+ ps -t 11 --sort=lstart -o user=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -o pid= -o ppid= -o command=
+ awk -v pane_pid=2068966
((/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]
}
+ pane_info=2069450:zentester:ssh -p 222 zentester@jumpbox -i /usr/lib/x86_64-linux-gnu/pkcs11/opensc-pkcs11.so
+ command=zentester:ssh -p 222 zentester@jumpbox -i /usr/lib/x86_64-linux-gnu/pkcs11/opensc-pkcs11.so
+ command=ssh -p 222 zentester@jumpbox -i /usr/lib/x86_64-linux-gnu/pkcs11/opensc-pkcs11.so
+ _ssh_or_mosh_args ssh -p 222 zentester@jumpbox -i /usr/lib/x86_64-linux-gnu/pkcs11/opensc-pkcs11.so
+ printf %s ssh -p 222 zentester@jumpbox -i /usr/lib/x86_64-linux-gnu/pkcs11/opensc-pkcs11.so
+ perl -n -e print if s/.*?\bssh[\w]*\s*((?:\s+-\w+)*)(\s+\w+)(\s\w+)?/\1\2/
+ args= -p 222@jumpbox -i /usr/lib/x86_64-linux-gnu/pkcs11/opensc-pkcs11.so
+ printf %s -p 222@jumpbox -i /usr/lib/x86_64-linux-gnu/pkcs11/opensc-pkcs11.so
+ ssh_or_mosh_args= -p 222@jumpbox -i /usr/lib/x86_64-linux-gnu/pkcs11/opensc-pkcs11.so
+ [ -n -p 222@jumpbox -i /usr/lib/x86_64-linux-gnu/pkcs11/opensc-pkcs11.so ]
+ ssh -G -p 222@jumpbox -i /usr/lib/x86_64-linux-gnu/pkcs11/opensc-pkcs11.so
+ awk /^hostname / { print $2; exit }
+ hostname=
+ [ -z ]
+ ssh -T -o ControlPath=none -o ProxyCommand=sh -c 'echo %%hostname%% %h >&2' -p 222@jumpbox -i /usr/lib/x86_64-linux-gnu/pkcs11/opensc-pkcs11.so
+ awk /^%hostname% / { print $2; exit }
+ hostname=
+ _is_true false
+ [ xfalse = xtrue ]
+ [ xfalse = xyes ]
+ [ xfalse = x1 ]
+ printf %s\n
Alright, we can see that the ssh
process was found:
pane_info=2069450:zentester:ssh -p 222 zentester@jumpbox -i /usr/lib/x86_64-linux-gnu/pkcs11/opensc-pkcs11.so
But the regex that tries to isolate the args fails
$ printf '%s' 'ssh -p 222 zentester@jumpbox -i /usr/lib/x86_64-linux-gnu/pkcs11/opensc-pkcs11.so' | perl -n -e 'print if s/.*?\bssh[\w]*\s*((?:\s+-\w+)*)(\s+\w+)(\s\w+)?/\1\2/'
-p 222@jumpbox -i /usr/lib/x86_64-linux-gnu/pkcs11/opensc-pkcs11.so
Let me debug that
Can you please try the gh-627
branch?
Looks like it worked!!!! Thank you for the quick and expedient help @gpakosz
That being said, your ssh invocation should likely be -I /usr/lib/x86_64-linux-gnu/pkcs11/opensc-pkcs11.so
with an upper case letter and not -i
Hi, on macOS (latest 'Sonoma') resolving of SSH hostname not working, tried hostname_full_ssh
, hostname_ssh
and hostname
. Printing empty value.
In same time this
ssh -G $ssh_or_mosh_args 2>/dev/null | awk '/^hostname / { print $2; exit }'
is printing remote hostname
pane_info='25239:ww7:zsh (cwterm)'
, seems no SSH process associated with that TTY
based on tmux display -p '#{pane_pid} #{b:pane_tty} false false #h #D'
before SSH
cut -c3- ~/.tmux.conf | sh -sx _hostname 25239 ttys005 false false mbp21 %0
+ :
+ set -e
+ unset GREP_OPTIONS
+ export LC_NUMERIC=C
+ LC_NUMERIC=C
+ set +H
+ set +H
+ printf ''
+ sed -E s///
++ uname -s
+ _uname_s=Darwin
+ '[' -z /private/tmp/tmux-502/default,24922,0 ']'
+ '[' -z /private/tmp/tmux-502/default ']'
+ '[' -z /opt/homebrew/Cellar/tmux/3.3a_3/bin/tmux ']'
+ '[' /opt/homebrew/Cellar/tmux/3.3a_3/bin/tmux = tmux ']'
++ tmux -V
++ /opt/homebrew/Cellar/tmux/3.3a_3/bin/tmux -S /private/tmp/tmux-502/default -V
++ awk '{gsub(/[^0-9.]/, "", $2); print ($2+0) * 100}'
+ _tmux_version=330
+ command -v pkill
+ _hostname 25239 ttys005 false false mbp21 %0
+ pane_pid=25239
+ pane_tty=ttys005
+ ssh_only=false
+ full=false
+ h_or_H=mbp21
++ _pane_info 25239 ttys005
++ pane_pid=25239
++ pane_tty=ttys005
++ case "$_uname_s" in
++ ps -t ttys005 -o user=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -o pid= -o ppid= -o command=
++ awk -v pane_pid=25239 '
((/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]
}
'
+ pane_info='25239:ww7:zsh (cwterm)'
+ command='ww7:zsh (cwterm)'
+ command='zsh (cwterm)'
++ _ssh_or_mosh_args 'zsh (cwterm)'
++ case "$1" in
++ printf %s ''
+ ssh_or_mosh_args=
+ '[' -n '' ']'
+ _is_true false
+ '[' false = true ']'
+ '[' false = yes ']'
+ '[' false = 1 ']'
+ hostname=mbp21
+ printf '%s\n' mbp21
mbp21
and
based on tmux display -p '#{pane_pid} #{b:pane_tty} false false #h #D'
after SSH
cut -c3- ~/.tmux.conf | sh -sx _hostname 3657818 5 false false a %1
+ :
+ set -e
+ unset GREP_OPTIONS
+ export LC_NUMERIC=C
+ LC_NUMERIC=C
+ set +H
+ set +H
+ printf ''
+ sed -E s///
++ uname -s
+ _uname_s=Darwin
+ '[' -z /private/tmp/tmux-502/default,24922,0 ']'
+ '[' -z /private/tmp/tmux-502/default ']'
+ '[' -z /opt/homebrew/Cellar/tmux/3.3a_3/bin/tmux ']'
+ '[' /opt/homebrew/Cellar/tmux/3.3a_3/bin/tmux = tmux ']'
++ tmux -V
++ /opt/homebrew/Cellar/tmux/3.3a_3/bin/tmux -S /private/tmp/tmux-502/default -V
++ awk '{gsub(/[^0-9.]/, "", $2); print ($2+0) * 100}'
+ _tmux_version=330
+ command -v pkill
+ _hostname 3657818 5 false false a %1
+ pane_pid=3657818
+ pane_tty=5
+ ssh_only=false
+ full=false
+ h_or_H=a
++ _pane_info 3657818 5
++ pane_pid=3657818
++ pane_tty=5
++ case "$_uname_s" in
++ ps -t 5 -o user=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -o pid= -o ppid= -o command=
++ awk -v pane_pid=3657818 '
((/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: /dev/tty5 and /dev/5: No such file or directory
+ pane_info=3657818::
+ command=:
+ command=
++ _ssh_or_mosh_args ''
++ case "$1" in
++ printf %s ''
+ ssh_or_mosh_args=
+ '[' -n '' ']'
+ _is_true false
+ '[' false = true ']'
+ '[' false = yes ']'
+ '[' false = 1 ']'
+ hostname=a
+ printf '%s\n' a
a (full is a.ww7.work)
@gpakosz I'm sorry, can you please take a look?
@ww7 👋
Please open a dedicated issue
Hello I'm trying to get the
hostname_ssh
variable to work. I'm assuming this means if I have my local system, calledlocalsystem
and I ssh into a remote system ofjumpbox
, it would displayjumpbox
in the bottom right hand corner when i'm ssh'd in, butlocalsystem
when I am not.I currently can get
localsystem
to display. However, when I ssh into the jumpbox, the display remains blank. I've tried this with both#{hostname_ssh}
variables by itself, as well as the conditional variable I have set below.Apologies if this is a rudimentary question, but it's been something I've tried digging into for a few hours but can't find clear guidance.
I'm also using zsh and oh-my-zsh.