soyuka / tmux-current-pane-hostname

Tmux plugin that enables displaying hostname and user of the current pane in your status bar.
MIT License
76 stars 23 forks source link

resolve #21 get_remote_info via ssh itself #24

Open tony-sol opened 4 months ago

tony-sol commented 4 months ago

Improve get_remote_info function by making it to fetch actual ssh configuration options (like host, port, user) via ssh -G and parse its output, instead of parsing ~/.ssh/config file.

This makes the plugin unbound from the .ssh/config file and more accurate in case of multiple Host some-wildcard* sections, e.g.:

Host prod-app
    Hostname 10.10.10.01
Host prod-db
    Hostname 10.10.10.10
Host prod-proxy
    Hostname 10.10.20.00
    Port 1337
Host prod-* !prod-proxy*
    ProxyJump 10.10.10.01
Host prod-*
    User provisioner
    Port 1134
    IdentityFile ...
So, on ssh prod-app correct values will be:
#U provisioner
#H prod-app
#{hostname_short} prod-app
#{pane_ssh_port} 1134

according to ssh -G prod-app | head -4

host prod-app
user provisioner
hostname 10.10.10.01
port 1134
And on ssh myself@prod-app -p 9999 correct values will be:
#U myself
#H prod-app
#{hostname_short} prod-app
#{pane_ssh_port} 9999

according to ssh -G myself@prod-app -p 9999 | head -4

host prod-app
user myself
hostname 10.10.10.01
port 9999
tony-sol commented 4 months ago

Great!

Sorry, but can't link this pr to issue https://github.com/soyuka/tmux-current-pane-hostname/issues/21

sysradium commented 4 months ago

I like this approach as well, because it works, for example, with ssh -v, unlike the original solution.

tony-sol commented 2 months ago

@soyuka is everything good?

sysradium commented 2 months ago

Probably busy giving talks :) I have been using the fork so far and all is good