I want use a script to modify the preferences of my terminal for my Mac, so it can close the window when exit the terminal. I use this command in the script:
/usr/libexec/PlistBuddy -c "Set \"Window Settings\":Basic:shellExitAction 0" ~/Library/Preferences/com.apple.Terminal.plist
Now the problem is after execute the script, the .plist file is do changed, I check it by
defaults read com.apple.Terminal "Window Settings"
The value is 0 now.
But the problem is the terminal not reload the .plist file, and when I exit the terminal, it rewrite the .plist file as '2' again. So my question is how to let terminal reload the .plist file when it's running or stop it rewrite the file when it exit.
In 10.9 (Mavericks), preferences are cached. After overwriting your preferences from Terminal, you need to read them with
defaults read com.apple.Terminal
and then Quit and restart Terminal.
I have my Terminal preferences on my server, so the full command I use on a new machine or in a new profile is:
curl -o ~/Library/Preferences/com.apple.Terminal.plist http://example.com/xyz/com.apple.Terminal.plist.`sw_vers \
| grep 'ProductVersion:' \
| grep -o '10\.[0-9]*'` \
&& defaults read com.apple.Terminal
My adapted solution runs in OS X Mavericks (too).
In the Example I add a new PermanentServer for a ssh connection in Terminal -p 22 www.example.com -l user -L 33306:localhost:3306
Open the plist-file in Xcode and edit the setting PermanentServer (copy and paste the string above)
open ~/Library/Preferences/com.apple.Terminal.plist
Open the Applescript-App and copy/paste/run following code:
do shell script "defaults read ~/Library/Preferences/com.apple.Terminal.plist"
Open Terminal-App and press SHIFT+CMD+K and looks in the serverlist
Thanks for this hint here: http://www.cnet.com/how-to/how-to-manually-edit-defaults-plist-files-in-mavericks/
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