Code Monkey home page Code Monkey logo

iterm2-theme-toggle's Introduction

A simple python script for setting the theme of iterm2 from where ever you want to invoke it.

Install

Prerequisites

You will need to allow third party applications to talk to the iterm api. This can be done with cookies and security BUT the api is horribly documented thus there is no security here (Smile and wave boys). To do this go to

Preferences -> General -> Magic -> Toggle "Enable Python API"
  • iTerm2 3.3.10 (because macOS and python 2.7 rip)

  • python3

  • pip3

1. Get the source

git clone https://github.com/brorbw/iterm2-theme-toggle.git [preferred location]

2. Then you will need to install the dependencies.

cd /where/you/installed/iterm2-theme-toggle
pipenv install

3. Last thing you will need is to invoke is

I have a line like this in my .zshrc but you can invoke the script with hammerspoon or whatever is to your liking.

function toggle-theme() {
	python3 ~/<install-path>/main.py "theme-name"
}

If you are experiencing issues like 'iTerm2' module not found, you can try the following solution

function toggle-theme() {
	BAK_PIPFILE=$PIPENV_PIPFILE
	(PIPENV_PIPFILE=~/Projects/iterm2-theme-toggle/Pipfile exec pipenv run python3 ~/Projects/iterm2-theme-toggle/main.py "theme-name")
	PIPENV_PIPFILE=$BAK_PIPFILE
	disown
}

First time you run the script iTerm2 will prompt you for permissions to you the API. Press always, if you don't want to allow it every time

Restart iTerm2 and you are good to go

Configuration

If you need to change the themes that it toggles between you just need to set the environment variables

iterm2-theme-toggle's People

Contributors

brorbw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

yh392261226

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.