From 7447160e7f3c9eb47823bf7c4e77df36b136bcd3 Mon Sep 17 00:00:00 2001 From: "Lockszmith (@VAST)" Date: Wed, 5 Mar 2025 14:34:36 -0500 Subject: [PATCH] add lsip to macos --- .../private_dot_local/bin/executable_lsip | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 _home.macos/private_dot_local/bin/executable_lsip diff --git a/_home.macos/private_dot_local/bin/executable_lsip b/_home.macos/private_dot_local/bin/executable_lsip new file mode 100644 index 0000000..5b989a7 --- /dev/null +++ b/_home.macos/private_dot_local/bin/executable_lsip @@ -0,0 +1,29 @@ +#! /usr/bin/env bash + +set -e + +is_cmd() { + type -p -- "${@}" 2> /dev/null 1> /dev/null +} + +if ! is_cmd ip; then + printf '%s\n' \ + '`ip` command missing, try again after installing:' \ + ' `brew install iproute2mac`' \ + '' + exit 1 +fi + +ip -j a s | jq -r ' + map(select(.operstate == "UP")) + | map(select(.addr_info | length > 0)) + | map(select(any(.addr_info[]; .family == "inet"))) + | sort_by(.addr_info[0].local // "0.0.0.0") + | .[] + | "\( .ifname )\t\( .link_type )\t\( + .addr_info[] + | select(.family == "inet") + | "\(.local)/\(.prefixlen)" + )" +' +