My fork of https://gist.github.com/jamesmacfie/2061023e5365e8b6bfbbc20792ac90f8 , adapted to also switch Emacs.
How to use
Copy the Python script to the following location:
Create the directory if it doesn't exist. Reboot iTerm2, and say "Yes" if it asks you to download a Python runtime.
This will automatically update Emacs themes, as well, through emacsclient. Make
sure you have Emacs running as a server in your init.el (
If Emacs isn't running, this script will skip it silently, no problem. But the emacsclient binary must exist.
For context, here's what I use for my init.el:
;; Start emacs in server mode, unless there already is one (when (and (require 'server nil :noerror) (not (server-running-p))) (server-start)) (defun hly/disable-themes () (mapc 'disable-theme custom-enabled-themes)) (defun hly/light-mode () (interactive) ;; I like the default theme. (hly/disable-themes)) (defun hly/dark-mode () (interactive) (hly/disable-themes) (load-theme 'tango-dark))
Changing what themes this uses
Note the constants at the top of the file. These are iTerm2 colour profiles, and Emacs functions (which you must define in your Emacs config) to actually switch the theme.