How to: automatic Dark Mode upon sunset including Safari, iTerm, Vim in macOS

November 25th, 2018

I must confess: I didn’t understand Dark Mode in the beginning nor did I see the reason behind it. When Mojave launched I remember being particularly impressed by Apple’s attention to detail, however I thought it was a feature I wouldn’t use. I was wrong. After some friends praised it recently I was intrigued. Gave it another spin for a while but I didn’t like a few things: i) macOS couldn’t switch between Light and Dark automatically like in Night Shift, ii) there was no easy way to switch between Light and Dark in my terminal environment (iTerm and Vim) which I exclusively use with Solarized, and iii) Safari web pages stayed in their default daylight whiteness. So, I reverted back to classic macOS.

Yet, a comment on Reddit was the spark to continue anew the challenge to fix the issues in my setup and automate the whole process. Thanks, u/SciGuy013!

Automatic switch between Light and Dark mode in iTerm and Vim

Here’s how I did it without messing with Apple Script, complicated setups, or dabbling too deep into obscure configuration files harming the “platform agnostic” factor of my dotfiles.

  1. In System Preferences > Displays > Night Shift enable Night Shift and set it to a sunset to sunrise schedule. (If you didn’t have Night Shift already enabled smh.)
  2. Download Shifty. Shifty is a free menu bar utility that gives you more control over Night Shift. After installing and running it, right click and open Preferences. There, simply check Scheduled Dark Mode. When enabled, Dark Mode will be automatically set based on the Night Shift schedule. Optionally, also set a keyboard shortcut for toggling Dark Mode. I used control + option + command + D. 1

    PS. I use brew cask to install non-App Store Mac apps: brew cask install shifty.

  3. Download Dark Reader for Safari. This extension creates dark themes for websites on the fly. It doesn’t blindly invert colors, it’s fast, and it’s absolutely worth its price. After enabling it in Safari settings, set it to Auto which means whenever it detects macOS running in Dark Mode it will convert websites to Dark Mode, too. 2

If you don’t use iTerm or Vim you’re ready. Enjoy switching between Light and Dark Mode automatically across every app and web content upon sunset and sunrise. If, on the other hand, you’re interested in using this setup for iTerm and Vim carry on, we’re almost there.

  1. First, duplicate your existing iTerm profile and change the color scheme. iTerm > Preferences > Profiles for duplicating and then Colors for switching to another scheme. Personally, I use Solarized Light and Dark. Name the new profile Dark.
  2. Put the following in your .bash_profile or .bashrc:
    if [[ "$(uname -s)" == "Darwin" ]]; then
        sith() {
            val=$(defaults read -g AppleInterfaceStyle 2>/dev/null)
            if [[ $val == "Dark" ]]; then
                i
            fi
        }
    
        i() {
            if [[ $ITERM_PROFILE == "Terminal" ]]; then
                echo -ne "\033]50;SetProfile=Dark\a"
                export ITERM_PROFILE="Dark"
            else
                echo -ne "\033]50;SetProfile=Terminal\a"
                export ITERM_PROFILE="Terminal"
            fi
        }
    
        sith
    fi

    Here’s what we’re doing: first we check if macOS is running in Dark Mode. If yes, we tell iTerm to switch to the Dark profile and update the $ITERM_PROFILE environment variable. (Otherwise, nothing happens. The i() function allows you to switch manually between profiles.)

  3. In your .vimrc put:
    let iterm_profile = $ITERM_PROFILE
    
    if iterm_profile == "Dark"
        set background=dark
    else
        set background=light        " Set solarized background color
    endif

    Here’s what’s happening: every time iTerm runs in Dark Mode (which we’ve set macOS to enable upon sunset,) Vim will set its background to dark (= Solarized Dark.) Otherwise, it’ll run with Light as before.

Et voila! We’ve completely automated switching from Light to Dark mode as well as utilizing this setup to change and maintain state in Safari, iTerm, and Vim.

As you can see, we’ve completely decoupled dynamic color switching from bash and Vim functionality, thus using and maintaining a leaner and more modular development environment.

To sum up, essentially we created an elaborate chain of reactions starting and based on Night Shift that goes something like this: if Night Shift on > Dark Mode on > bash switches iTerm profiles > Vim switches background colors. Very simple and elegant.

If you’ve got a better idea on how to achieve this setup or a similar one, let me know.


  1. I also dislike random menu bar utilities (always try to keep the bare minimum on: Dropbox, Magnet, Wi Fi, time, and date. Not even 1Password visible. Trust me, this is good.)
  2. You can configure per-site settings or just dim. You can read more Dark Reader in this Reddit thread. The developer is also very hands on and helpful. Overall, great app.

In conversation with Michael Kratsios

October 22nd, 2018

In September I moderated a fireside chat with Michael Kratsios at Tech Olympus Summit, a TED-style, tailor-made one-day conference hosting conversations in the areas of innovation, technology, creative industries, and civic engagement. Its inaugural edition is supported by the US Embassy in Greece, on the occasion of the 83rd Thessaloniki International Fair.

Michael is the Deputy Assistant for Technology Policy to the President and Deputy US CTO at the White House. He previously was Chief of Staff and Principal at Thiel Capital and before that he worked in banking.

(Fun trivia: when I visited Thiel Capital HQ and met with Peter back in 2011, Michael was in New York.)

We covered a lot of ground—from regulating emerging technologies, to 5G, space, drones, the President’s technology agenda, & Greek–US tech interoperability on both G2G and industry levels.

You can watch our discussion below via Youtube courtesy of Found.ation.

My Kathimerini Op-Ed: Σχέδια μακράς πνοής για μια ρευστή εποχή

October 10th, 2018

"Software is eating the world" according to Marc Andreessen. The upcoming tech and AI transformation only spins faster the ringing grooves of change. Digital transformation and digitalization of government public-facing services is not enough—we also need look the big picture with regards to tech. Because, paraphrasing Hemingway, those who can’t compete will be left behind. Gradually, then suddenly.

George and I argue in an op-ed in today’s Kathimerini for redefining Greece’s role in global affairs by focusing in strategic industries such as tech, energy, and shipping with a mix of long-term dynamic & model based thinking. Having a non-partisan council, which is responsible for developing and using the model to enhance the prime-ministerial decision making process, is key in fundamentally changing how these issues are perceived and acted upon on the highest governmental level.

Job displacement without retraining policies in place will be brutal. AI automation will make it harder to compete. Data-based services are already changing consumer behavior. This doesn’t mandate retreating from the global world society and markets, or not acting because the task at hand might be difficult to complete. Conversely, we must act. We must embrace tech transforming everything—from healthcare to freight logistics.

The op-ed is in Greek. I might translate it at a later time. For now, I’m reproducing it in full below.

Από τους κύριους στόχους της πολιτείας τον 21ο αιώνα είναι ο εκσυγχρονισμός των δημόσιων υπηρεσιών. Σε αυτόν τον στόχο εντάσσονται η ενοποίηση και η ψηφιοποίηση του γραφειοκρατικού μηχανισμού. Αν και δεν έχουμε φθάσει στο επίπεδο του Ηνωμένου Βασιλείου (λ.χ. Gov.uk και Government Digital Service), των ΗΠΑ (Congressional Innovation Fellows, Presidential Innovation Fellows), ή της πρωτοπόρου Εσθονίας, έχουμε κάνει σημαντικά βήματα. Μένει λοιπόν να τα συνεχίσουμε.

Πέραν όμως του να επισκευάσουμε τις «λακκούβες στον δρόμο», πρέπει να δούμε προς τα πού μας οδηγεί ο δρόμος. Ο αυξανόμενος ρυθμός εξέλιξης της τεχνολογίας προκαλεί αλλαγές που πρέπει η πολιτεία να παρακολουθήσει. Αλλιώς, ρισκάρει να έρθει αντιμέτωπη με τον ιστορικά ιδιάζοντα κίνδυνο της απομόνωσης, όπως έγραψε ο Χέμινγουεϊ: σταδιακά και στη συνέχεια ξαφνικά.

Η σταδιακή μετάλλαξη των ανεπτυγμένων χωρών από οικονομίες υπηρεσιών σε οικονομίες γνώσης αναπροσαρμόζει κάθε εργασιακό κλάδο. Στην οικονομία της γνώσης το «λογισμικό τρώει τους πάντες» κατά τον Μαρκ Αντρέεσεν, συνιδρυτή του φημισμένου επενδυτικού fund Andreessen Horowitz. Η απάντηση σε αυτές τις αλλαγές δεν μπορεί να μας βρει ως νέους λουδίτες να στεκόμαστε απέναντι στην Ιστορία φωνάζοντας «στοπ!». Πρέπει να τις οικειοποιηθούμε με κριτική ματιά και με επίκεντρο τον πολίτη.

Οι αλλαγές αυτές μπορούν να αποτελέσουν το θεμέλιο για ένα σχέδιο επαναπροσδιορισμού της θέσης της Ελλάδας στον παγκόσμιο χάρτη, με έμφαση σε στρατηγικούς τομείς όπως η τεχνολογία, η ενέργεια, η γεωπολιτική και η ναυτιλία. Αυτό πρέπει να γίνει στη βάση ενός μακροπρόθεσμου και βασισμένου σε δυναμικά μοντέλα τρόπου σκέψης που θα επικουρεί την πρωθυπουργική διαδικασία λήψης αποφάσεων ανεξαρτήτως του ποιος βρίσκεται στο Μαξίμου. Υπεύθυνοι για το σχέδιο αυτό θα είναι στελέχη με διεπιστημονικό υπόβαθρο και εμπειρία από τους χώρους της διπλωματίας, της δημόσιας διοίκησης, των ενόπλων δυνάμεων, αλλά και του ιδιωτικού τομέα.

Ο σχεδιασμός αυτός πρέπει να διαχειριστεί τις πολυεπίπεδες μεταβολές που θα επιφέρει η νέα τεχνολογική επανάσταση – φαινόμενα όπως η μετατόπιση εργασιών, ο κλασικός αλλά και μέσω τεχνητής νοημοσύνης αυτοματισμός, η πιθανή αναδιοργάνωση των τραπεζικών συναλλαγών κ.ά. Οι απαντήσεις στις προκλήσεις αυτές πρέπει να δοθούν συνδυαστικά, αξιοποιώντας τα συγκριτικά πλεονεκτήματα της Ελλάδας (λ.χ. υψηλής ποιότητας ανθρώπινο δυναμικό).

Είμαστε μια σεβαστή μεσαία δύναμη, μία από τις τρεις σταθερές δημοκρατίες της ασταθούς περιοχής μας. Εχουμε μια οικονομία που και σήμερα είναι μεγαλύτερη όλων των υπολοίπων βαλκανικών (ακόμη και αν τις αθροίσουμε), με το μεγαλύτερο εμπορικό στόλο παγκοσμίως, γεννάμε δειλά δειλά επιτυχημένα τεχνολογικά startups και αρχίζουμε να μπαίνουμε δυναμικά στην ενεργειακή βιομηχανία της Ευρώπης. Παρότι έχουμε μείνει πίσω στην ψηφιακή κούρσα, λίγες δυνάμεις έχουν αρχίσει να σκέφτονται σοβαρά για αυτά τα ζητήματα. Αν σηκώσουμε τα μανίκια, μπορούμε να καλύψουμε το χαμένο έδαφος και να πάμε πραγματικά μπροστά.

Books I want to read, fall 2018

September 23rd, 2018

This is a list of some of the reading I plan to do this fall. It’s not exhaustive but indicative of my picks and discussions lately. The books were recommended to me by new (hi Manju!) and old friends. When germane, I’ve also included relevant material. You think I missed something I should definitely read? Let me know on Twitter.

I’ve also compiled a similar list of podcasts I listen to. It covers topics like tech and biotech, Apple, philosophy, economics, culture, business, finance, literature, history, aviation, and TV. Have a look.

The Things They Carried

AmazonGoodreads

Published in 1990, The Things They Carried is a collection of twenty-two linked short stories (a novel, according to some) by Tim O’Brien. It depicts the men of Alpha Company battling the enemy (or maybe more the idea of the enemy,) and occasionally each other.

Relevant reading: The absolutely essential and legendary Why Men Love War, published in the November 1984 issue of Esquire. “Like all lust, for as long as it lasts it dominates everything else.”

Infinite Jest

AmazonGoodreads

David Foster Wallace’s masterpiece. A gargantuan, mind-altering comedy about the Pursuit of Happiness. Equal parts philosophical quest and screwball comedy, Infinite Jest bends every rule of fiction without sacrificing for a moment its own entertainment value.

Relevant reading: This is Water, DFW’s classic Kenyon commencement speech. Consider the Lobster, a collection of essays that are also enthralling narrative adventures.

A Perfect Day for Bananafish

AmazonGoodreads (Part of Nine Stories)

J.D. Salinger’s seminal short story originally published in the January 31, 1948 issue of The New Yorker. The story is an enigmatic examination of a young married couple, Muriel and Seymour Glass, while on vacation in Florida. It is considered the story that would permanently change Salinger’s standing in the literary community.

Relevant reading: A short story I recently read and deeply enjoyed: The Gospel According to Mark, included in Brodie’s Report, a collection of Jorge Louis Borges’ works. It has a powerful quote (and a favorite of mine:)

It also occurred to him that throughout history, humankind has told two stories: the story of a lost ship sailing the Mediterranean seas in quest of a beloved isle, and the story of a god who allows himself to be crucified on Golgotha.

The Brief Wondrous Life of Oscar Wao

AmazonGoodreads

Diaz immerses us in the history of the family at large, rendering with genuine warmth and dazzling energy, humor, and insight the Dominican-American experience, and, ultimately, the endless human capacity to persevere in the face of heartbreak and loss. Considered a recent literary triumph.

A Confederacy of Dunces

AmazonGoodreads

Toole’s classic masterpiece. It was published posthumously, over a decade after Toole ended his own life, and won the Pulitzer Prize. The many subplots that weave through A Confederacy of Dunces are as complicated as anything you’ll find in a Dickens novel, and just as beautifully tied together in the end. Ignatius, a selfish, domineering, deluded, tragic, comic, and larger than life, carries the story.

The Power and the Glory

AmazonGoodreads

Greene’s novel tells the story of a renegade Roman Catholic whisky priest (a term coined by Greene) living in the Mexican state of Tabasco in the 1930s during a time when the Mexican government was attempting to suppress the Catholic Church. That suppression had resulted in the Cristero War, so named for its Catholic combatants’ slogan Viva Cristo Rey (“Long live Christ the King.”) Too human for heroism, too humble for martyrdom, the nameless little worldly “whiskey priest” is nevertheless impelled toward his squalid Calvary as much by his own compassion for humanity as by the efforts of his pursuers.

Relevant reading: Silence by Shūsaku Endō. The story of a Jesuit missionary sent to 17th century Japan, who endures persecution in the time of Kakure Kirishitan. Further relevant material is the short story The Gospel According to Mark of Borges, already linked above.

And watching: Also directed into a movie by Scorcese (a great one, that is) which I include in my canon: “a list of films that alien lifeforms should use to try and understand mankind; hopefully they’ll have an easier job of it than we do.”

When

AmazonGoodreads

Drawing on a rich trove of research from psychology, biology, and economics, Pink reveals how timing works. Why do certain breaks dramatically improve student test scores? How can we turn a stumbling beginning into a fresh start? Why should we avoid going to the hospital in the afternoon? Why is singing in time with other people as good for you as exercise?

Lastly, a bonus TED talk: Are you a giver or a taker? Organizational psychologist and Wharton professor Adam Grant breaks down the three basic kinds of people personalities (givers, takers, matchers) and offers simple strategies to promote a culture of generosity and keep self-serving employees from taking more than their share.