From b313d393660594eb9cd0fc80dd3473b93db17f6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 14 Aug 2023 15:07:53 +0800 Subject: [PATCH] LocalIP (macOS): improve detection When a VPN session is enabled, the default route interface is changed to `utun*`, however `ipconfig` doesn't support it for some reason Use `ifconfig` instead --- neofetch | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/neofetch b/neofetch index 48b96d21..c0f199fe 100755 --- a/neofetch +++ b/neofetch @@ -3878,10 +3878,10 @@ get_local_ip() { "Mac OS X" | "macOS" | "iPhone OS") if [[ "${local_ip_interface[0]}" == "auto" ]]; then interface="$(route get 1 | awk -F': ' '/interface/ {printf $2; exit}')" - local_ip="$(ipconfig getifaddr "$interface")" + local_ip="$(ifconfig "$interface" | grep "inet " | awk '{print $2}')" else for interface in "${local_ip_interface[@]}"; do - local_ip="$(ipconfig getifaddr "$interface")" + local_ip="$(ifconfig "$interface" | grep "inet " | awk '{print $2}')" if [[ -n "$local_ip" ]]; then prin "$interface" "$local_ip" else