Jump to content

Recommended Posts

Posted

<div class="KonaBody"><p><img src="http://osxdaily.com/wp-content/uploads/2011/05/multiple-instances-of-application-mac.jpg" alt="Run Multiple Instances of Any Application in Mac OS X" title="multiple-instances-of-application-mac" width="480" height="144" class="aligncenter size-full wp-image-15904" /></p>

<p>You can run multiple instances of any application in Mac OS X with a little command line magic. Using the ‘open’ command to <a href="http://osxdaily.com/2007/02/01/how-to-launch-gui-applications-from-the-terminal/">launch GUI apps from the Terminal</a>, we can run a new instance of any app, even if it is already running. </p>

<p>In the simplest form, we just point open to the application with the -n flag. For a practical example, we’ll use the Safari browser:</p>

<p><code>open -n /Applications/Safari.app/</code></p>

<p>This will launch a new instance of Safari, even if Safari is already open. You can repeat this command to launch as many instances of the app that you want running.</p>

<p>Instead of repeating the command over and over again though, let’s make it even easier to launch multiple instances of the app though. What if you want to launch five new instances of Safari? Assuming you’re using bash, we’ll use this command:</p>

<p><code style="font-size:95%;">n=5 ; for (( c=1; c<=n; c++)) ; do open -n /Applications/Safari.app/ ; done</code></p>

<p>Now that's a bit of a complicated string to type over and over again, so we'll make it easier by <a href="http://osxdaily.com/2007/05/31/command-line-shortcut-for-lengthy-ssh-command/">creating an alias</a> in your .bash_profile:</p>

<p>First you need to open .bash_profile in a text editor, nano is nice and easy:</p>

<p><code>nano ~/.bash_profile</code></p>

<p>Now paste this into a new line (assuming there's other aliases in there from our <a href="http://osxdaily.com/2011/04/12/connect-wireless-network-command-line/">recent tips</a> or otherwise), just make sure everything is on a single line:</p>

<p><code style="font-size:90%;">alias safarix5='n=5 ; for (( c=1; c<=n; c++)) ; do open -n /Applications/Safari.app/ ; done'</code></p>

<p>Save changes to .bash_profile by hitting Control+O and hitting return</p>

<p>I named the alias 'safarix5' for Safari X 5, since that string launches 5 instances of Safari, but you can call it whatever you want. If you wanted to run Safari in 10 different instances, it's just a matter of changing the variable 'n' like so:</p>

<p><code style="font-size:90%;">alias safarix10='n=10 ; for (( c=1; c<=n; c++)) ; do open -n /Applications/Safari.app/ ; done'</code></p>

<p>You can change the application to anything you want, just remember that each running instance of an app consumes the full amount of resources for that app. Web and app developers should be particularly happy with this trick, but there are plenty of other uses as well.</p>

<p>If you enjoyed this, <a href="http://osxdaily.com/category/command-line/">check out more command line tips and tricks</a>.</p>

</div>

<p><a href="http://feedads.g.doubleclick.net/~a/forMJfwZy00CxoZUuxzrajQKL4w/0/da"><img src="http://feedads.g.doubleclick.net/~a/forMJfwZy00CxoZUuxzrajQKL4w/0/di" border="0" ismap="true"></img></a><br/>

<a href="http://feedads.g.doubleclick.net/~a/forMJfwZy00CxoZUuxzrajQKL4w/1/da"><img src="http://feedads.g.doubleclick.net/~a/forMJfwZy00CxoZUuxzrajQKL4w/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">

<a href="http://feeds.feedburner.com/~ff/osxdaily?a=bTIQy4W1BfQ:OP0uNq5IfM0:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/osxdaily?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/osxdaily?a=bTIQy4W1BfQ:OP0uNq5IfM0:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/osxdaily?i=bTIQy4W1BfQ:OP0uNq5IfM0:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/osxdaily?a=bTIQy4W1BfQ:OP0uNq5IfM0:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/osxdaily?i=bTIQy4W1BfQ:OP0uNq5IfM0:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/osxdaily?a=bTIQy4W1BfQ:OP0uNq5IfM0:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/osxdaily?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/osxdaily?a=bTIQy4W1BfQ:OP0uNq5IfM0:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/osxdaily?d=qj6IDK7rITs" border="0"></img></a>

</div><img src="http://feeds.feedburner.com/~r/osxdaily/~4/bTIQy4W1BfQ" height="1" width="1"/>

 

View the full article

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic


×
×
  • Create New...