iTerm profile switch

This commit is contained in:
Yann Esposito (Yogsototh) 2019-11-10 22:15:00 +01:00
parent 2b90505d7b
commit b132ed3ce1
Signed by untrusted user who does not match committer: yogsototh
GPG key ID: 7B19A4C650D59646
4 changed files with 43 additions and 43 deletions

View file

@ -54,14 +54,14 @@
(concat
"<div class=\"content\">"
(menu '("<a href=\"#postamble\">↓ bottom ↓</a>"))
"<h1>"
(format "%s" (car (plist-get info :title)))
"</h1>"
(when-let ((date (plist-get info :date)))
(format "<span class=\"article-date\">%s</span>"
(format-time-string "%Y-%m-%d"
(org-timestamp-to-time
(car date)))))
"<h1>"
(format "%s" (car (plist-get info :title)))
"</h1>"
(when-let ((subtitle (car (plist-get info :subtitle))))
(format "<h2>%s</h2>" subtitle))
"</div>"))

Binary file not shown.

View file

@ -766,7 +766,7 @@ blockquote:after, .main blockquote:after {
pre span.org-builtin {color:var(--cyan);}
pre span.org-string {color:var(--green);}
pre span.org-doc {color:var(--green);}
pre span.org-keyword {color:var(--blue);}
pre span.org-keyword {color:var(--green);}
pre span.org-variable-name {color:var(--blue);}
pre span.org-function-name {color:var(--blue);}
pre span.org-type {color:var(--yellow);}

View file

@ -6,6 +6,10 @@
#+DESCRIPTION: Small script to change the profile of iTerm in sync with macOS preferences
#+OPTIONS: auto-id:t toc:t
#+begin_notes
How to have dark/light profile selected when opening a new iTerm.
#+end_notes
* The script
:PROPERTIES:
:CUSTOM_ID: the-script
@ -21,50 +25,46 @@ I use =fish= but you can easily adapt that in your =.bashrc=,
Here is what I have in my =~/.config/fish/config.fish=:
#+begin_src fish
function setItermProfile
echo -ne "\033]50;SetProfile=$argv\a"
end
function setItermProfile
echo -ne "\033]50;SetProfile=$argv\a"
end
function sync_appearance
function sync_appearance
set -x MacOSThemeAutoSwitch \
(defaults read -g AppleInterfaceStyleSwitchesAutomatically 2>/dev/null)
test -z $MacOSThemeAutoSwitch; and set -x MacOSThemeAutoSwitch 0
set -x MacOSThemeAutoSwitch \
(defaults read -g AppleInterfaceStyleSwitchesAutomatically 2>/dev/null)
test -z $MacOSThemeAutoSwitch; and set -x MacOSThemeAutoSwitch 0
set -x MacOSTheme (defaults read -g AppleInterfaceStyle 2>/dev/null)
test -z $MacOSTheme; and set -x MacOSTheme 'nil'
set -x MacOSTheme (defaults read -g AppleInterfaceStyle 2>/dev/null)
test -z $MacOSTheme; and set -x MacOSTheme 'nil'
# for debug purpose only
# echo $MacOSThemeAutoSwitch
# echo $MacOSTheme
if test -n $ITERM_PROFILE # check if we are using iTerm2
switch $MacOSThemeAutoSwitch
case 1 # autoswitch on
switch $MacOSTheme
case 'nil'
setItermProfile Light
case '*'
setItermProfile Dark
end
case 0 # autoswitch off
switch $MacOSTheme
case 'Dark'
setItermProfile Dark
case 'Light'
setItermProfile Light
case 'nil'
setItermProfile Light
end
end
end
end
if test -n $ITERM_PROFILE # check if we are using iTerm2
switch $MacOSThemeAutoSwitch
case 1
switch $MacOSTheme
case 'nil'
setItermProfile Light
case '*'
setItermProfile Dark
end
case 0
switch $MacOSTheme
case 'Dark'
setItermProfile Dark
case 'Light'
setItermProfile Light
case 'nil'
setItermProfile Light
end
end
end
end
if status --is-login
if status --is-interactive
sync_appearance
end
end
if status --is-login
if status --is-interactive
sync_appearance
end
end
#+end_src
If the appearance change, you can call =sync_appearance= function in your