22

When I want to run my Scala project, I cd to the project directory and do

$ sbt "run arg1"

How can I do the same operation from outside the project directory?

dhg
  • 52,383
  • 8
  • 123
  • 144

1 Answers1

28

My answer is inpired by this more general question: How do I run a program with a different working directory from current, from Linux shell?

(cd myPath/; sbt "run arg1")

or

(cd myPath/ && exec sbt "run arg1")
Community
  • 1
  • 1
Christopher Chiche
  • 15,075
  • 9
  • 59
  • 98
  • Thanks. This works. The one downside I'm seeing is that it puts a `target` directory in the working directory instead of using the `target` directory that is already in the project directory. Is there a way to stop it from doing that? – dhg Jul 11 '12 at 07:18
  • Generally it works! Remember to remove double quote of sbt command. – stanleyxu2005 Mar 09 '15 at 05:35
  • 6
    If you want to go back to your original directory, just append `cd -`. example `cd myPath; sbt "run arg1"; cd -` – Muhammad Hewedy Jun 27 '15 at 19:27