[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:
commit
5c785f0819
1 changed files with 2 additions and 2 deletions
4
neofetch
4
neofetch
|
@ -4935,10 +4935,10 @@ get_local_ip() {
|
||||||
"Mac OS X" | "macOS" | "iPhone OS")
|
"Mac OS X" | "macOS" | "iPhone OS")
|
||||||
if [[ "${local_ip_interface[0]}" == "auto" ]]; then
|
if [[ "${local_ip_interface[0]}" == "auto" ]]; then
|
||||||
interface="$(route -n get 1 | awk -F': ' '/interface/ {printf $2; exit}')"
|
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
|
else
|
||||||
for interface in "${local_ip_interface[@]}"; do
|
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
|
if [[ -n "$local_ip" ]]; then
|
||||||
prin "$interface" "$local_ip"
|
prin "$interface" "$local_ip"
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue