Copy Internal IP to Clipboard

// Name: Internal IP
// Description: Get Internal IP address and copy it to the clipboard
// Author: Bjorn Beishline
import "@johnlindquist/kit";
try {
let ip = (await $`ifconfig -l | xargs -n1 ipconfig getifaddr`)?._combined;
copy(ip)
} catch (error) {
copy(error?._combined)
}

Now I know this might look weird, but zx throws an error when running ifconfig -l | xargs -n1 ipconfig getifaddr, because ipconfig getifaddr <interface name> throws an error when getting say en1 (at least on my machine). Regardless the command is still successful as it will retrieve the actual internal IP address regardless.