From 399ac740fafd8d08906b668038095c7c9d186231 Mon Sep 17 00:00:00 2001 From: Joakim Hulthe Date: Wed, 25 Jun 2025 18:06:42 +0200 Subject: [PATCH] Parse user in `tailscale ssh` nu command --- tree/.local/nu/tailscale.nu | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tree/.local/nu/tailscale.nu b/tree/.local/nu/tailscale.nu index 82282f5..beb4a0f 100644 --- a/tree/.local/nu/tailscale.nu +++ b/tree/.local/nu/tailscale.nu @@ -33,10 +33,15 @@ def "tailscale peer" [ # SSH to a tailscale peer def "tailscale ssh" [ - hostname: string + user_hostname: string ...ssh_flags: string ]: nothing -> any { - ssh -o $"HostName (tailscale peer $hostname | get ipv6)" $hostname ...$ssh_flags + if "@" in $user_hostname { + let parsed = ($user_hostname | parse "{user}@{hostname}" | first) + ssh -o $"HostName (tailscale peer $parsed.hostname | get ipv6)" $user_hostname ...$ssh_flags + } else { + ssh -o $"HostName (tailscale peer $user_hostname | get ipv6)" $user_hostname ...$ssh_flags + } } # SCP to a tailscale peer @@ -47,7 +52,7 @@ def "tailscale scp" [ ]: nothing -> any { let options = ( - [$from, $to] | + [$from, $to] | parse "{hostname}:{path}" | each { |it| $"HostName (tailscale peer $it.hostname | get ipv6)" } | each { |option| ["-o", $option] } |