[PR] dylanaraps/neofetch#2362 from CarterLi - LocalIP (macOS): improve detection

Upstream PR: https://github.com/dylanaraps/neofetch/pull/2362
Thanks to @CarterLi

Co-authored-by: 李通洲 <zhangsongcui3371@sina.com>
This commit is contained in:
Azalea 2023-08-14 20:19:46 -07:00
commit 5c785f0819

View file

@ -4935,10 +4935,10 @@ get_local_ip() {
"Mac OS X" | "macOS" | "iPhone OS")
if [[ "${local_ip_interface[0]}" == "auto" ]]; then
interface="$(route -n 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