Skip to content

Instantly share code, notes, and snippets.

@matiaskorhonen
Created January 28, 2021 10:47
Show Gist options
  • Save matiaskorhonen/700106343a553013066d929aee10da89 to your computer and use it in GitHub Desktop.
Save matiaskorhonen/700106343a553013066d929aee10da89 to your computer and use it in GitHub Desktop.
Override the iOS Simulator status bar in all running simulators
function statusbarmagic() {
usage="Usage: statusbarmagic apply|clear|help"
arg="$1"
requirements=( xcrun jq )
missing=0
for c in "${requirements[@]}"
do
if ! command -v "$c" &> /dev/null
then
echo "$c could not be found"
missing=$(expr $missing + 1)
fi
done
if [[ $missing -gt 0 ]]
then
return 1
fi
case $arg in
apply)
;;
clear)
;;
help)
echo "$usage"
return 0
;;
*)
echo "$usage"
return 2
;;
esac
xcrun simctl list devices available --json | jq -r '.devices|map(.)|flatten|.[]|select(.state == "Booted")|.name' | \
while read device
do
printf "$device…"
case $arg in
apply)
xcrun simctl status_bar "$device" override --time 9:41 --dataNetwork wifi --wifiMode active --wifiBars 3 --cellularMode active --cellularBars 4 --batteryState charged --batteryLevel 100
;;
clear)
xcrun simctl status_bar "$device" clear
;;
esac
printf "\b: ✅ \n"
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment