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 (concat
"<div class=\"content\">" "<div class=\"content\">"
(menu '("<a href=\"#postamble\">↓ bottom ↓</a>")) (menu '("<a href=\"#postamble\">↓ bottom ↓</a>"))
"<h1>"
(format "%s" (car (plist-get info :title)))
"</h1>"
(when-let ((date (plist-get info :date))) (when-let ((date (plist-get info :date)))
(format "<span class=\"article-date\">%s</span>" (format "<span class=\"article-date\">%s</span>"
(format-time-string "%Y-%m-%d" (format-time-string "%Y-%m-%d"
(org-timestamp-to-time (org-timestamp-to-time
(car date))))) (car date)))))
"<h1>"
(format "%s" (car (plist-get info :title)))
"</h1>"
(when-let ((subtitle (car (plist-get info :subtitle)))) (when-let ((subtitle (car (plist-get info :subtitle))))
(format "<h2>%s</h2>" subtitle)) (format "<h2>%s</h2>" subtitle))
"</div>")) "</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-builtin {color:var(--cyan);}
pre span.org-string {color:var(--green);} pre span.org-string {color:var(--green);}
pre span.org-doc {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-variable-name {color:var(--blue);}
pre span.org-function-name {color:var(--blue);} pre span.org-function-name {color:var(--blue);}
pre span.org-type {color:var(--yellow);} 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 #+DESCRIPTION: Small script to change the profile of iTerm in sync with macOS preferences
#+OPTIONS: auto-id:t toc:t #+OPTIONS: auto-id:t toc:t
#+begin_notes
How to have dark/light profile selected when opening a new iTerm.
#+end_notes
* The script * The script
:PROPERTIES: :PROPERTIES:
:CUSTOM_ID: the-script :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=: Here is what I have in my =~/.config/fish/config.fish=:
#+begin_src fish #+begin_src fish
function setItermProfile function setItermProfile
echo -ne "\033]50;SetProfile=$argv\a" echo -ne "\033]50;SetProfile=$argv\a"
end end
function sync_appearance function sync_appearance
set -x MacOSThemeAutoSwitch \ set -x MacOSThemeAutoSwitch \
(defaults read -g AppleInterfaceStyleSwitchesAutomatically 2>/dev/null) (defaults read -g AppleInterfaceStyleSwitchesAutomatically 2>/dev/null)
test -z $MacOSThemeAutoSwitch; and set -x MacOSThemeAutoSwitch 0 test -z $MacOSThemeAutoSwitch; and set -x MacOSThemeAutoSwitch 0
set -x MacOSTheme (defaults read -g AppleInterfaceStyle 2>/dev/null) set -x MacOSTheme (defaults read -g AppleInterfaceStyle 2>/dev/null)
test -z $MacOSTheme; and set -x MacOSTheme 'nil' test -z $MacOSTheme; and set -x MacOSTheme 'nil'
# for debug purpose only if test -n $ITERM_PROFILE # check if we are using iTerm2
# echo $MacOSThemeAutoSwitch switch $MacOSThemeAutoSwitch
# echo $MacOSTheme 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 if status --is-login
switch $MacOSThemeAutoSwitch if status --is-interactive
case 1 sync_appearance
switch $MacOSTheme end
case 'nil' end
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
#+end_src #+end_src
If the appearance change, you can call =sync_appearance= function in your If the appearance change, you can call =sync_appearance= function in your