#!/usr/bin/ruby # nocterm.rb: change the terminal colors for night-vision mode # may 25, 2009 # john chesley # update may 28, 2009: added support for toggling emacs color-theme # uses emacsclient, so put (server-start) in your .emacs if it's not there # see http://john.cheslicious.com/stuff/nocterm for more info require 'appscript' include Appscript # themes to toggle in Terminal and emacs term_noc_theme = "Nocturne" term_normal_theme = "Pro" emacs_noc_theme = "black-on-gray" emacs_normal_theme = "dark-laptop" emacs_colors = emacs_normal_theme term = app('Terminal') # 1.upto() because windows[0] and windows[1] represent the same window 1.upto(term.windows.count) {|x| window = term.windows[x] w_name = window.name.get if (w_name.grep(/Visor/) == []) then puts "#{x}: " + window.current_settings.name.get if window.current_settings.name.get == term_noc_theme then term_colors = term.settings_sets[term_normal_theme] emacs_colors = emacs_normal_theme else term_colors = term.settings_sets[term_noc_theme] emacs_colors = emacs_noc_theme end # apply new settings window.tabs.current_settings.set(term_colors) term.default_settings.set(term_colors) end } system("emacsclient -e \\(color-theme-#{emacs_colors}\\)") app("Finder").startup_disk.folders["Applications"].application_files["Nocturne.app"].open