Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reload com.apple.Terminal.plist

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.

like image 924
owenwater Avatar asked Dec 01 '11 23:12

owenwater


2 Answers

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
like image 97
mivk Avatar answered Oct 27 '22 01:10

mivk


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

  1. Close the Terminal-App
  2. Open the plist-file in Xcode and edit the setting PermanentServer (copy and paste the string above)

    open ~/Library/Preferences/com.apple.Terminal.plist

  3. Save and close the plist-file
  4. Open the Applescript-App and copy/paste/run following code:

    do shell script "defaults read ~/Library/Preferences/com.apple.Terminal.plist"

  5. 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/

like image 26
Dierk Avatar answered Oct 27 '22 00:10

Dierk