Skip to content

Instantly share code, notes, and snippets.

@iilei
Created February 17, 2014 19:58
Show Gist options
  • Save iilei/9057898 to your computer and use it in GitHub Desktop.
Save iilei/9057898 to your computer and use it in GitHub Desktop.
open any page within Safari running on iOS Simulator from the terminal
#!/bin/bash
# best used with an alias.
# then simply run `ios example.com` (assuming `ios` is an alias for this script) to open http://example.com
# ios simulator. As I am using it mainly for running jasmine I pointed it to http://localhost:8888 by default.
# Change it as you will.
#first option: url - with or without http:// - can be omitted completely.
if [ -n "$1" ]
then
if [[ $string =~ ^https?: ]]
then
URL="$1"
else
# prepend http://
URL="http://$1"
fi
else
# default url to visit
URL="http://localhost:8888"
fi
# second option: append "keep" to preserve open tabs
if [ ! "keep" == "$2" ]
then
find ~/Library/Application\ Support/ -path '*Safari/SuspendState.plist' -exec rm {} \;
fi
`/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app/Contents/MacOS/iPhone\ Simulator -SimulateApplication /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.0.sdk/Applications/MobileSafari.app/MobileSafari -u $URL`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment