Skip to content

Instantly share code, notes, and snippets.

@Flowdeeps
Last active December 14, 2016 10:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Flowdeeps/cbb94c3a4118d01c11958bb0398fb090 to your computer and use it in GitHub Desktop.
Save Flowdeeps/cbb94c3a4118d01c11958bb0398fb090 to your computer and use it in GitHub Desktop.

Shhfari

Somebody at work asked me if it was possible to open Safari (10) in Private Browsing mode in the same way it's possible to do for Chrome. The answer is yes. Sort of.

Method

Open a terminal window and paste this into it.

mkdir ~/.scripts

then all in one go

read -d '' shhfari <<- EOF
#!/usr/bin/osascript
tell application "Safari" to activate
tell application "System Events"
tell process "Safari"
click menu item "New Private Window" of menu "File" of menu bar 1
end tell
end tell
EOF
echo "$shhfari" > ~/.scripts/shhfari.applescript

then

chmod +x ~/.scripts/shhfari.applescript

then

echo 'alias shhfari="~/.scripts/shhfari.applescript"' >> ~/.bash_profile

finally

source ~/.bash_profile

Result

Now when you type:

shhfari

into your terminal it will open open a new Private Browsing window.

It is not elegant.

Edits

Made the big script one-liner a bit more user friendly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment