Apparently the correct way to find the place to store an application's data in OSX is to call in ObjectiveC
NSArray* theDirs = [[NSFileManager defaultManager]
URLsForDirectory:NSApplicationSupportDirectory inDomains:NSUserDomainMask]
Normally that would return /Users/<username>/Library/Application Support
How can I get that from bash script? Yes I know I could just do this
DIR="${HOME}/Library/Application Support"
But that's not really the correct way to do it. You're supposed to ask the OS so it can give you the actual directory. (might be on the network for example?).
Yes, I suppose I could write a small ObjectiveC app just to return that path but I'm assuming there's got to be a standard way to do this?
One way is use AppleScript and its System Events
helper application. osascript
allows you to run AppleScript from the command line:
DIR="$(osascript \
-e 'tell application "System Events"' \
-e 'get POSIX path of (path to application support folder from user domain)' \
-e 'end tell')"
echo $DIR
--> /Users/nad/Library/Application Support
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With