Couple of weeks ago, a friend of mine, who mainly uses Linux operating system, complained that when he tries to open a new window of Safari in different desktop, the operating system automatically switches back to the desktop (spaces) that the safari is running.
In Linux, as in MAC, you can have multiple virtual desktops. This helps to organize the programs that are running simultaneously. Particularly, once you have many windows and application running at the same time. However, in Linux once you click on Firefox icon, the Firefox will start working in that desktop.
However, this is not the case on MAC OS X. Once you click on the Safari or Firefox icon, it takes you back to the original desktop where you started this application for the first time. This also happens when you use Command+N to open a new window.
Well, one quick work around is to open the new window and then move it to your desired desktop. But I do agree this is not solving the problem but rather more of erasing the problem or changing the question.
Well, then let’s solve the problem for real.
In linux, once you click on the Firefox icon, the operating system starts a new instance of that software, with completely different Process ID (PID). However, in MAC it does not do that. Even when you are opening a new window, that new window is still running under the same PID. You can check the PID using /Applications/Utilities/Activity Monitor.
So, all we need to do is to force the MAC to start a new instance. But how?
If you are using the command prompt (Terminal), you can do this by typing:
open -n /Applications/Safari.app
You can execute this command as many times as you want. Each time a new instance of Safari with totally different PID is going to run. But remember, you also get multiple icon of Safari on the Dock, as you get multiple tab on windows or Linux. So, if you have 10 instances of Safari, there are going to be 10 Safari icon on the Dock. Exactly as in windows and Linux. This may justify why MAC is not running multiple instances of the same application by default.
If you want to have multiple instances of Firefox, or any other application, you just need to provide the path to that application in the above command.
One way to make this easier, is to make an alias for each command, such as:
alias NewSafari=’open -n /Applications/Safari.app’
This is easier. Now you just need to type NewSafari in the command prompt and you get your new instance of Safari. You can also put this line in your ~/.profile; so every time that you fire up the terminal, this command is available.
But still this is not the solution. Since, this requires first running the terminal and then running a command. What we are looking here is an icon on the dock, which once clicked opens a new instance of the Safari, or any other application of your choice.
Here what you should do:
Step 1: Open AppleScript Editor. Just type AppleScript in spotlight and then enter.
Step 2: After the AppleScript editor opened, type the following command in it.
do shell script "open -n /Applications/Safari.app"
NOTE: if you are copy/pasting the above script, make sure to retype the double quotes, i.e. “. WordPress uses a different character code, which looks nicer; however, it is not recognizable by apple script. So, either type the entire command, or if you copy/paste retype the double quotes again.
Step 3: Now chose File -> ‘Save Aa’, choose a name, for example Safari, and make sure that “Application” is selected in “File Format”.
I have a folder called ~/myscripts where I store all the scripts that I write. You may also want to have a folder to store your scripts.
Practically you are done. By clicking on this application that you just created a new instance of Safari is opened every time that you click it. You can drag it to the dock so you can access it even faster.
However, the icon does not look like Safari icon yet. If you want to change the icon of this new application that you just wrote, follow these easy step.
Step 1: Right click on /Applications/Safari and choose “Get Info”. Then in the Get Info window click on the Safari Icon. Once the icon started to glow, press command+c.
Step 2: Now right click on the application that you wrote, eg. ~/myscripts/Safari.app, and choose “Get Info”. Click on the icon on top. Once it starts to glow, press command+v.
That was it. You changed the icon. Now you can put this on the dock and whenever you want to start a new instance of safari, just click on this icon.
NOTE: for the workaround for Firefox go to here.
Hope this was helpful.