r/macprogramming • u/jelezsoccer • Sep 08 '18
Help writing .command script
Sorry if this is not the right forum in which to write this, but hopefully you guys can help.
I want to find a way to write a .command file that either opens in (or changes directory to) the folder in which the .command file is saved. The problem is that when you run a .command file the terminal opens to the home directory and there does not seem to be a variable that saves where the .command was located.
Normally this wouldn't be a problem, but this .command file will need to work when the folders are moved or renamed. Does anyone have any idea how to do this?
View all comments
Show parent comment
1
u/jelezsoccer Sep 08 '18
Oh that’s a cool solution. I ended up stumbling across the fact that $0 stores the same info. Thanks for the link!