0

I have this command already working in my .bash_profile:

alias mysite='cd /Applications/sites/mysite;pwd; php artisan serve --port=9000 | open http://localhost:9000 | open -a Finder ./'

So it:

  • CD's into the folder
  • Starts artisan serve
  • Opens a new browser window at that address
  • Opens a new Finder window at that same location

What i would like it to do, is add a new command to do something like:

open -a Terminal cd /Applications/sites/mysite

So it opens a new Terminal window, and cd's int that new terminal window to the same folder.

Is it possible? I've tried this:

alias mysite='cd /Applications/sites/mysite;pwd; php artisan serve --port=9000 | open http://localhost:9000 | open -a Finder ./ | open -a Terminal cd /Applications/sites/mysite'

But i can't make it work. It does everything as in the first example but it never opens the new terminal window :(

Thanks in advance!

1 Answer 1

0

I don't think the last part of your command (open -a Terminal cd /Applications/sites/mysite) works, as the argument is not passed to be executed as a command, see a similar question here.

One workaround is to use AppleScript for last part:

osascript -e 'tell application "Terminal" to do script "cd /Applications/sites/mysite"'

To include this in your alias definition, make sure all single/double quotes match and escape where necessary:

alias mysite='cd /Applications/sites/mysite; pwd; php artisan serve --port=9000 | open http://localhost:9000 | open -a Finder ./ | osascript -e "tell application \"Terminal\" to do script \"cd /Applications/sites/mysite\""'

Does that work for you?

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .