Skip to content

Conversation

gileswells
Copy link

Primarily I wanted to incorporate @amartignoni's simplification through networksetup over use of a private API and implement a fix for issue #28 so that I had a one stop branch that would do what I needed.

This covers both scenarios.

Closes #29

@smilinggoat
Copy link

Turns out this breaks support for SSIDs with spaces in the name. It only matches the final " lastword".

@KuuDS
Copy link

KuuDS commented Apr 8, 2024

fix for SSIDs with spaces

networksetup -listallhardwareports | awk '/Wi-Fi/{getline; print $2}' | xargs networksetup -getairportnetwork | sed 's/[^:]*: //'

@smilinggoat
Copy link

fix for SSIDs with spaces

networksetup -listallhardwareports | awk '/Wi-Fi/{getline; print $2}' | xargs networksetup -getairportnetwork | sed 's/[^:]*: //'

That worked for me. Thanks!

@fujimite
Copy link

fujimite commented Oct 1, 2024

fix for SSIDs with spaces

networksetup -listallhardwareports | awk '/Wi-Fi/{getline; print $2}' | xargs networksetup -getairportnetwork | sed 's/[^:]*: //'

Unfortunately this is broken as of MacOS 15.0. And I haven't been able to find any way to fix it without sudo, as every non-sudo command I've found lists the SSID as "<redacted>"

@CalumnShearer
Copy link

CalumnShearer commented Oct 10, 2024

Try system_profiler SPAirPortDataType | grep -A2 'Status: Connected' | tail -n1 | sed 's/:$//' | xargs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants