aboutsummaryrefslogtreecommitdiffstats
path: root/.osx
diff options
context:
space:
mode:
authorCătălin Mariș <alrraa@gmail.com>2015-02-04 20:03:34 +0200
committerMathias Bynens <mathias@qiwi.be>2015-02-04 20:07:10 +0100
commit1f6ead4fca779e498672a39403aa6926280fdfa0 (patch)
tree6fde291a326a84d49a8fb1c8b3b3b52f63a950dd /.osx
parentfdb4c901b44d1891b314c2c324088ed993a0f71d (diff)
downloaddotfiles-1f6ead4fca779e498672a39403aa6926280fdfa0.tar.gz
dotfiles-1f6ead4fca779e498672a39403aa6926280fdfa0.tar.bz2
dotfiles-1f6ead4fca779e498672a39403aa6926280fdfa0.zip
.osx: Fix code that sets the custom terminal theme
Fix the `.osx` script so that it correctly sets the custom terminal theme, and the change will be persistent. Closes #492.
Diffstat (limited to '.osx')
-rwxr-xr-x.osx53
1 files changed, 45 insertions, 8 deletions
diff --git a/.osx b/.osx
index d38fb9e..080854b 100755
--- a/.osx
+++ b/.osx
@@ -564,14 +564,51 @@ sudo mdutil -E / > /dev/null
defaults write com.apple.terminal StringEncodings -array 4
# Use a modified version of the Solarized Dark theme by default in Terminal.app
-TERM_PROFILE='Solarized Dark xterm-256color';
-CURRENT_PROFILE="$(defaults read com.apple.terminal 'Default Window Settings')";
-if [ "${CURRENT_PROFILE}" != "${TERM_PROFILE}" ]; then
- open "${HOME}/init/${TERM_PROFILE}.terminal";
- sleep 1; # Wait a bit to make sure the theme is loaded
- defaults write com.apple.terminal 'Default Window Settings' -string "${TERM_PROFILE}";
- defaults write com.apple.terminal 'Startup Window Settings' -string "${TERM_PROFILE}";
-fi;
+osascript <<EOD
+
+tell application "Terminal"
+
+ local allOpenedWindows
+ local initialOpenedWindows
+ local windowID
+ set themeName to "Solarized Dark xterm-256color"
+
+ (* Store the IDs of all the open terminal windows. *)
+ set initialOpenedWindows to id of every window
+
+ (* Open the custom theme so that it gets added to the list
+ of available terminal themes (note: this will open two
+ additional terminal windows). *)
+ do shell script "open '$HOME/init/" & themeName & ".terminal'"
+
+ (* Wait a little bit to ensure that the custom theme is added. *)
+ delay 1
+
+ (* Set the custom theme as the default terminal theme. *)
+ set default settings to settings set themeName
+
+ (* Get the IDs of all the currently opened terminal windows. *)
+ set allOpenedWindows to id of every window
+
+ repeat with windowID in allOpenedWindows
+
+ (* Close the additional windows that were opened in order
+ to add the custom theme to the list of terminal themes. *)
+ if initialOpenedWindows does not contain windowID then
+ close (every window whose id is windowID)
+
+ (* Change the theme for the initial opened terminal windows
+ to remove the need to close them in order for the custom
+ theme to be applied. *)
+ else
+ set current settings of tabs of (every window whose id is windowID) to settings set themeName
+ end if
+
+ end repeat
+
+end tell
+
+EOD
# Enable “focus follows mouse” for Terminal.app and all X11 apps
# i.e. hover over a window and start typing in it without clicking first