tmux status: show VPN IP when tunnel is active
Add tmux-vpn-ip helper (parses ifconfig for utun* on macOS, falls back to tun/wg/ppp on Linux) and a tmux-net wrapper that conditionally emits "⌂ <local> / ⇡ <vpn>" when a VPN tunnel is up, or just "<local>" when it's not. status-right now calls tmux-net.
This commit is contained in:
17
.local/bin/tmux-net
Executable file
17
.local/bin/tmux-net
Executable file
@@ -0,0 +1,17 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Emit the tmux status-bar network segment.
|
||||
# No VPN: "<local_ip>"
|
||||
# VPN up: "<local_ip> (local) / <vpn_ip> (vpn)"
|
||||
#
|
||||
|
||||
set -u
|
||||
|
||||
local_ip=$("$HOME/.local/bin/tmux-ip" 2>/dev/null || true)
|
||||
vpn_ip=$("$HOME/.local/bin/tmux-vpn-ip" 2>/dev/null || true)
|
||||
|
||||
if [ -n "${vpn_ip:-}" ]; then
|
||||
printf '\xe2\x8c\x82 %s / \xe2\x87\xa1 %s\n' "${local_ip:-}" "$vpn_ip"
|
||||
else
|
||||
printf '%s\n' "${local_ip:-}"
|
||||
fi
|
||||
Reference in New Issue
Block a user