Skip to content

Commit 3f892b2

Browse files
Merge pull request #303 from fvincenzo/master
mac: Fix network detection
2 parents 2a9c6e9 + 499aef3 commit 3f892b2

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

scripts/network.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,13 @@ get_ssid()
2424
;;
2525

2626
Darwin)
27-
if ipconfig getsummary en0 | awk -F ' SSID : ' '/ SSID : / {print $2}'; then
28-
wifi_label=$(get_tmux_option "@dracula-network-wifi-label" "")
29-
echo "$wifi_label$(ipconfig getsummary en0 | awk -F ' SSID : ' '/ SSID : / {print $2}')"
27+
local wifi_network=$(ipconfig getsummary en0 | awk -F ' SSID : ' '/ SSID : / {print $2}')
28+
local airport=$(networksetup -getairportnetwork en0 | cut -d ':' -f 2)
29+
30+
if [[ $airport != "You are not associated with an AirPort network." ]]; then
31+
echo "$wifi_label$airport" | sed 's/^[[:blank:]]*//g'
32+
elif [[ $wifi_network != "" ]]; then
33+
echo "$wifi_label$wifi_network" | sed 's/^[[:blank:]]*//g'
3034
else
3135
echo "$ethernet_label"
3236
fi

0 commit comments

Comments
 (0)