From 131a08eff9e4828f76e7eb3e5bec09420af10563 Mon Sep 17 00:00:00 2001 From: Ivan Verevkin Date: Wed, 10 Feb 2016 13:41:43 +0700 Subject: [PATCH] Add plugin for dynamic switch iTerm2 theme I want to dynamically change the theme in iterm2 depending on the time of day --- plugins/iterm2-dynamic-theme/Readme.md | 10 ++++++++++ .../iterm2-dynamic-theme.plugin.zsh | 20 +++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 plugins/iterm2-dynamic-theme/Readme.md create mode 100644 plugins/iterm2-dynamic-theme/iterm2-dynamic-theme.plugin.zsh diff --git a/plugins/iterm2-dynamic-theme/Readme.md b/plugins/iterm2-dynamic-theme/Readme.md new file mode 100644 index 00000000..2cdb5161 --- /dev/null +++ b/plugins/iterm2-dynamic-theme/Readme.md @@ -0,0 +1,10 @@ +## + +**Maintainer:** [@idoo](https://github.com/idoo) + +This plugin switch iTerm2 theme depends on the time of day + +### Usage + +Please create two profile with name `dark` and `light` + diff --git a/plugins/iterm2-dynamic-theme/iterm2-dynamic-theme.plugin.zsh b/plugins/iterm2-dynamic-theme/iterm2-dynamic-theme.plugin.zsh new file mode 100644 index 00000000..3624969b --- /dev/null +++ b/plugins/iterm2-dynamic-theme/iterm2-dynamic-theme.plugin.zsh @@ -0,0 +1,20 @@ +function set_iterm_profile() { + echo -e "\033]50;SetProfile=$1\a" +} + +function start_dynamic_theme() { + HOUR=`date +%H` + if [ $HOUR -ge 8 -a $HOUR -le 17 ]; then + set_iterm_profile light + else + set_iterm_profile dark + fi +} + +start_dynamic_theme &! + +while true +do + start_dynamic_theme + sleep 600 +done