There is a lot of questions and articles about the "When switching to an application, switch to a Space with open windows for the application" under the mission control settings pane (also called "Auto Swoosh") such as here and here.
My issue with this setting is that some applications are used very differently from each other. For example when I want to switch to Spotify I probably also want to move to its space. However, some app (notably web browsers) I'd like the behaviour to be different. Specifically I usually have many safari windows across many spaces and when I switch to safari I probably would want to open a new window in my current space (so I don't want to be switched to a random space).
The best way I see to fix this is some ability to customise the Auto Swoosh setting on a per app basis. I've also been thinking of alternative solutions such as keeping the option off and using apple script or something to make a shortcut to switch to the space with the active window (like a one time manual invocation of Auto Swoosh), or a keeping it the option on and finding a different way of opening safari windows (such as typing in my search into spotlight and using cmd+B to google search it) however nothing works quite as I'd like it to.
What are some options I could use to get to the behaviour I want? My main thing is being able to navigate my computer without using the mouse and without searching through spaces it find the app I want.
Best Answer
I finally figured out a way to do it. I've kept the Auto Swoosh setting on but I've changed the way I open safari. I created a new application using automator with a single applescript block. It has the following code:
The order is important because its what prevents the spaces switching on activate as there is already a new window in the current space.
To open a new safari window in my current space I simply run this app.
(In case it doesn't make any sense how this is fast, I use spotlight as an app switcher - simply type the first two letters of any app)
EDIT:
I've made a new version that also supports opening links. This is so that when you click a link in e.g. Mail it opens a new safari windows instead of randomly moving to a different space where safari is already open.
Specifically:
Note: the code is modified from here
Save this in AppleScript as application and set it as default browser using this or this.
Copy the following into the app's info.plist to register it as allowing for link opening
Accept app permissions (for some reason the app needs to be in the /Applications folder first). And voila! Now just change the app icon to the safari icon and retain your muscle memory to type the name of this app instead of "safari" when opening new browser windows. (I have put way too much effort into this but after months of using it, I'm so happy with the change)