Hacker News new | past | comments | ask | show | jobs | submit login
Change OSX Terminal theme on the fly when you SSH (tempe.st)
10 points by intinig on April 7, 2011 | hide | past | favorite | 8 comments



Interesting bug in this example:

Since the AppleScript instructs the terminal to change _the current session_'s theme, if ssh exits while you're in another tab (say due to a disconnect), the tab which is currently frontmost will have its theme changed to 'Solarized Dark', while the tab you had run ssh in will stay as 'Solarized Light'.

Of course, this won't show up in testing -- and will be rather surprising when it does show up. :-)


I hate Terminal's AppleScript implementation. For example, this does not work:

   tell application "Terminal"
      set my_tab to first tab of first window
      get container of my_tab
   end tell
In nearly everything else I've seen, "get container of" works.

Or consider this. It changes the settings of the first tab of the first window to the first settings set. It works great:

   tell application "Terminal"
      set current settings of first tab of first window to first settings set
   end tell
However, a trivial change that in any sane implementation would be exactly equivalent fails:

   tell application "Terminal"
      set first_set to first settings set
      set current settings of first tab of first window to first_set
   end tell
Changing it slightly makes it work:

   tell application "Terminal"
      set first_set to a reference to first settings set
      set current settings of first tab of first window to first_set
   end tell
AppleScript is the most frustrating language I've ever tried to work with because of things like this.


You are right about the bug, I should check whether the terminal applescript interface allows changing the theme of a named session.


That's kind of nifty, but I still prefer reading the hostname on the connection. I use a variation of Steve Losh's awesome zsh prompt and that helps make things petty obvious (if anything, because some of the remote shells won't have the beefed up prompt)


I also have the hostname on the prompt, but sometimes having a contrasting theme can help :)


Sorry, but I can't see sh*t on those Solarized themes which you call the "best theme ever created".


Well thanks for sharing, I guess; a lot of people apparently really like those themes if the recent HN thread is anything to go by: http://news.ycombinator.com/item?id=2393976

Anyway, that wasn't the point of the post; you could use this technique just as well with whatever color schemes that you can see shit on.


I am sorry you can't see a lot with Solarized, but the script works with any theme :)




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: