user1495306
user1495306

Reputation: 131

Enter current directory - mac

I am on mac and I have a .command file which on double click should run my script and hence the application opens.

But the issue is that the application runs from the root folder and not the current folder. How can I automate the way, that the application first automatically enters my current directory and then proceed.

Probably some cd statement at top of the script

Upvotes: 5

Views: 2273

Answers (1)

Jatin
Jatin

Reputation: 31724

Do cd "$(dirname "$0")" to enter the current directory. And have your respective code after it.

Upvotes: 6

Related Questions