Skip to content

Instantly share code, notes, and snippets.

@henri
Last active December 12, 2022 21:26
Show Gist options
  • Save henri/439c108c0265262d523d9a766b02b04d to your computer and use it in GitHub Desktop.
Save henri/439c108c0265262d523d9a766b02b04d to your computer and use it in GitHub Desktop.
macOS switch to specific network location
#!/bin/bash
# simple script for macOS systems. It will switch to the location specified below if it is exists.
switch_to_location="Automatic"
current_location=`scselect | grep "*" | grep -v "Defined sets include: " | awk -F "(" '{print $2}' | awk -F ")" '{print $1}'`
if [ "{$current_location}" != "{$switch_to_location}" ] ; then
scselect "${switch_to_location}"
exit $?
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment