Merge branch 'master' of gitea.esy.fun:yogsototh/her.esy.fun
This commit is contained in:
commit
444548b8f5
|
@ -1,5 +1,8 @@
|
||||||
#!/usr/bin/env zsh
|
#!/usr/bin/env zsh
|
||||||
|
|
||||||
|
cd "$(git rev-parse --show-toplevel)" || exit 1
|
||||||
|
source ./engine/envvars.sh
|
||||||
|
|
||||||
## colors for tput
|
## colors for tput
|
||||||
# black=0
|
# black=0
|
||||||
red=1
|
red=1
|
||||||
|
@ -13,8 +16,11 @@ green() { printf "$(tput setaf $green)%s$(tput sgr0)" "$*" }
|
||||||
yellow() { printf "$(tput setaf $yellow)%s$(tput sgr0)" "$*" }
|
yellow() { printf "$(tput setaf $yellow)%s$(tput sgr0)" "$*" }
|
||||||
blue() { printf "$(tput setaf $blue)%s$(tput sgr0)" "$*" }
|
blue() { printf "$(tput setaf $blue)%s$(tput sgr0)" "$*" }
|
||||||
|
|
||||||
tee >(lorri watch | sed 's/^/[lorri] /' ) \
|
pipegreen() {while read line; do green $line; done}
|
||||||
>(./engine/serve.sh | sed 's/^/[http] /') \
|
pipeyellow() {while read line; do yellow $line; done}
|
||||||
>(./engine/auto-build.sh | sed 's/^/[make] /') \
|
pipeblue() {while read line; do blue $line; done}
|
||||||
>(sleep 1 && open 'http://127.0.0.1:3000')
|
|
||||||
|
|
||||||
|
tee >(lorri watch | sed 's/^/[lorri] /' | pipegreen ) \
|
||||||
|
>(./engine/serve.sh | sed 's/^/[http] /' | pipeyellow) \
|
||||||
|
>(./engine/auto-build.sh | sed 's/^/[make] /' | pipeblue) \
|
||||||
|
>(sleep 1 && open 'http://127.0.0.1:3000')
|
||||||
|
|
|
@ -14,9 +14,11 @@ before=$(sizeof $src)
|
||||||
|
|
||||||
if [[ "${src:e}" == "gif" ]]; then
|
if [[ "${src:e}" == "gif" ]]; then
|
||||||
after=$(sizeof $dst)
|
after=$(sizeof $dst)
|
||||||
|
dest=$dst
|
||||||
else
|
else
|
||||||
cwebp "$dst" -quiet -o "$dst.webp"
|
cwebp "$dst" -quiet -o "$dst.webp"
|
||||||
after=$(sizeof $dst.webp)
|
after=$(sizeof $dst.webp)
|
||||||
|
dest=$dst.webp
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,154 @@
|
||||||
|
;;; doom-zen-writer-theme.el --- -*- lexical-binding: t; no-byte-compile: t; -*-
|
||||||
|
;;
|
||||||
|
;; Author: Yann Esposito <https://github.com/yogsototh>
|
||||||
|
;; Created: October 24, 2021
|
||||||
|
;; Version: 1.0.0
|
||||||
|
;; Keywords: custom themes, faces
|
||||||
|
;; Homepage: https://github.com/hlissner/emacs-doom-themes
|
||||||
|
;; Package-Requires: ((emacs "25.1") (cl-lib "0.5") (doom-themes "2.2.1"))
|
||||||
|
;;
|
||||||
|
;;; Code:
|
||||||
|
|
||||||
|
(require 'doom-themes)
|
||||||
|
|
||||||
|
;;
|
||||||
|
;;; Variables
|
||||||
|
|
||||||
|
(defgroup doom-plain-theme nil
|
||||||
|
"Options for the `doom-plain' theme."
|
||||||
|
:group 'doom-themes)
|
||||||
|
|
||||||
|
(defcustom doom-plain-padded-modeline doom-themes-padded-modeline
|
||||||
|
"If non-nil, adds a 4px padding to the mode-line.
|
||||||
|
Can be an integer to determine the exact padding."
|
||||||
|
:group 'doom-plain-theme
|
||||||
|
:type '(or integer boolean))
|
||||||
|
|
||||||
|
|
||||||
|
;;
|
||||||
|
;;; Theme definition
|
||||||
|
|
||||||
|
(def-doom-theme doom-zen-writer
|
||||||
|
"Theme inspired by gko's plain."
|
||||||
|
|
||||||
|
;; name default/256/16
|
||||||
|
((bg '("#ffffff"))
|
||||||
|
(bg-alt '("#eaecea"))
|
||||||
|
(base0 '("#969896"))
|
||||||
|
(base1 '("#f1f3f5"))
|
||||||
|
(base2 '("#606666"))
|
||||||
|
(base3 '("#cccccc"))
|
||||||
|
(base4 '("#e7e7e7"))
|
||||||
|
(base5 '("#a5a8a6"))
|
||||||
|
(base6 '("#fafafa"))
|
||||||
|
(base7 '("#dfdfdf"))
|
||||||
|
(base8 '("#fafafa"))
|
||||||
|
(fg '("#969896"))
|
||||||
|
(fg-alt (doom-lighten fg 0.15))
|
||||||
|
|
||||||
|
(grey fg)
|
||||||
|
(red fg)
|
||||||
|
(blue fg)
|
||||||
|
(dark-blue fg)
|
||||||
|
(orange fg)
|
||||||
|
(green fg)
|
||||||
|
(teal fg)
|
||||||
|
(yellow fg)
|
||||||
|
(magenta fg)
|
||||||
|
(violet fg)
|
||||||
|
(cyan fg)
|
||||||
|
(dark-cyan fg)
|
||||||
|
|
||||||
|
;; face categories -- required for all themes
|
||||||
|
(highlight base2)
|
||||||
|
(vertical-bar base5)
|
||||||
|
(selection base1)
|
||||||
|
(builtin base0)
|
||||||
|
(comments base5)
|
||||||
|
(doc-comments base5)
|
||||||
|
(constants base0)
|
||||||
|
(functions fg)
|
||||||
|
(keywords fg)
|
||||||
|
(methods fg)
|
||||||
|
(operators fg)
|
||||||
|
(type fg)
|
||||||
|
(strings base0)
|
||||||
|
(variables base0)
|
||||||
|
(numbers base0)
|
||||||
|
(region base4)
|
||||||
|
(error (doom-blend fg "#ff0000" 0.4))
|
||||||
|
(warning base2)
|
||||||
|
(success green)
|
||||||
|
(vc-modified base5)
|
||||||
|
(vc-added (doom-lighten fg 0.7))
|
||||||
|
(vc-deleted base2)
|
||||||
|
|
||||||
|
;; custom categories
|
||||||
|
(-modeline-pad
|
||||||
|
(when doom-plain-padded-modeline
|
||||||
|
(if (integerp doom-plain-padded-modeline) doom-plain-padded-modeline 4)))
|
||||||
|
|
||||||
|
(modeline-bg (doom-darken bg-alt 0.15))
|
||||||
|
(modeline-bg-alt (doom-darken bg-alt 0.1))
|
||||||
|
(modeline-bg-inactive (doom-darken bg-alt 0.1))
|
||||||
|
(modeline-bg-inactive-alt bg-alt)
|
||||||
|
(modeline-fg fg)
|
||||||
|
(modeline-fg-alt (doom-darken modeline-bg-inactive 0.35)))
|
||||||
|
|
||||||
|
;;;; Base theme face overrides
|
||||||
|
((error :underline `(:style wave :color ,error))
|
||||||
|
(warning :underline `(:style wave :color ,warning))
|
||||||
|
(hl-sentence :foreground "#000000" :background bg)
|
||||||
|
((font-lock-constant-face &override) :slant 'italic)
|
||||||
|
((font-lock-comment-face &override) :slant 'italic)
|
||||||
|
((font-lock-function-name-face &override) :slant 'italic)
|
||||||
|
((font-lock-type-face &override) :slant 'italic)
|
||||||
|
(hl-line :background base8)
|
||||||
|
((line-number &override) :foreground base3)
|
||||||
|
((line-number-current-line &override) :foreground base2)
|
||||||
|
(mode-line
|
||||||
|
:background modeline-bg :foreground modeline-fg
|
||||||
|
:box (if -modeline-pad `(:line-width ,-modeline-pad :color ,modeline-bg)))
|
||||||
|
(mode-line-inactive
|
||||||
|
:background modeline-bg-inactive :foreground modeline-fg-alt
|
||||||
|
:box (if -modeline-pad `(:line-width ,-modeline-pad :color ,modeline-bg-inactive)))
|
||||||
|
(mode-line-emphasis :foreground highlight)
|
||||||
|
|
||||||
|
;;;; doom-modeline
|
||||||
|
(doom-modeline-bar :background modeline-bg)
|
||||||
|
(doom-modeline-bar-inactive :inherit 'doom-modeline-bar)
|
||||||
|
(doom-modeline-project-dir :foreground fg)
|
||||||
|
(doom-modeline-buffer-file :foreground fg)
|
||||||
|
(doom-modeline-buffer-modified :weight 'bold :foreground "#000000")
|
||||||
|
(doom-modeline-panel :inherit 'mode-line-highlight :background base3 :foreground fg)
|
||||||
|
;;;; ivy
|
||||||
|
(ivy-posframe :background bg-alt)
|
||||||
|
;;;; magit
|
||||||
|
((magit-diff-added-highlight &override) :foreground fg :background (doom-blend vc-added bg 0.3))
|
||||||
|
((magit-diff-removed &override) :foreground (doom-lighten fg 0.4) :background (doom-blend vc-deleted bg 0.1))
|
||||||
|
((magit-diff-removed-highlight &override) :foreground fg :background (doom-blend vc-deleted bg 0.22))
|
||||||
|
;;;; lsp-mode
|
||||||
|
(lsp-headerline-breadcrumb-symbols-face :foreground keywords :weight 'bold)
|
||||||
|
;;;; outline <built-in>
|
||||||
|
(outline-1 :slant 'italic :foreground fg-alt)
|
||||||
|
(outline-2 :inherit 'outline-1 :foreground base2)
|
||||||
|
(outline-3 :inherit 'outline-2)
|
||||||
|
(outline-4 :inherit 'outline-3)
|
||||||
|
(outline-5 :inherit 'outline-4)
|
||||||
|
(outline-6 :inherit 'outline-5)
|
||||||
|
(outline-7 :inherit 'outline-6)
|
||||||
|
(outline-8 :inherit 'outline-7)
|
||||||
|
;;;; org <built-in>
|
||||||
|
((org-block &override) :background bg-alt)
|
||||||
|
((org-block-begin-line &override) :foreground base5)
|
||||||
|
;;;; solaire-mode
|
||||||
|
(solaire-mode-line-face
|
||||||
|
:inherit 'mode-line
|
||||||
|
:background modeline-bg-alt
|
||||||
|
:box (if -modeline-pad `(:line-width ,-modeline-pad :color ,modeline-bg-alt)))
|
||||||
|
(solaire-mode-line-inactive-face
|
||||||
|
:inherit 'mode-line-inactive
|
||||||
|
:background modeline-bg-inactive-alt
|
||||||
|
:box (if -modeline-pad `(:line-width ,-modeline-pad :color ,modeline-bg-inactive-alt)))))
|
||||||
|
|
||||||
|
;;; doom-plain-theme.el ends here
|
342
src/posts/0021-ia-writer-clone-within-doom-emacs/index.org
Normal file
342
src/posts/0021-ia-writer-clone-within-doom-emacs/index.org
Normal file
|
@ -0,0 +1,342 @@
|
||||||
|
#+title: iA writer clone within doom-emacs
|
||||||
|
#+description:
|
||||||
|
#+keywords: emacs org-mode
|
||||||
|
#+author: Yann Esposito
|
||||||
|
#+email: yann@esposito.host
|
||||||
|
#+date: [2021-10-24 Sun]
|
||||||
|
#+lang: en
|
||||||
|
#+options: auto-id:t
|
||||||
|
#+startup: showeverything
|
||||||
|
|
||||||
|
So I played with tweaking my emacs configuration again.
|
||||||
|
I think I made something worth to be shared.
|
||||||
|
I wanted to have the same effect than in iA writer within emacs.
|
||||||
|
And I just reached this.
|
||||||
|
|
||||||
|
So the effect I am looking to achieve can be seen in this video.
|
||||||
|
|
||||||
|
#+name: demo video
|
||||||
|
#+begin_export html
|
||||||
|
<video src="./zen-writer-demo.mov" width="100%" controls autoplay>
|
||||||
|
<a href="./zen-writer-demo.mov">zen-writer-demo video (7.2MB)</a>
|
||||||
|
</video>
|
||||||
|
#+end_export
|
||||||
|
#+begin_comment
|
||||||
|
=> ./zen-writer-demo.mov zen-writer-demo video (7.2MB)
|
||||||
|
#+end_comment
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
It highlight the current sentence (in black) while the rest of the text is
|
||||||
|
gray.
|
||||||
|
The main issue with the =hl-sentence= package alone is that it set a specific
|
||||||
|
face to the current sentence, but does not affect the other text in the
|
||||||
|
buffer.
|
||||||
|
In fact to make it work as I would expect, you need to make the default
|
||||||
|
color grey, and only set black for the highlighted text.
|
||||||
|
|
||||||
|
Fortunately, I have recently created a personal theme close to that.
|
||||||
|
I just created a new specific one.
|
||||||
|
Everything is mostly "gray" except the font ~hl-sentence~ which is black.
|
||||||
|
|
||||||
|
And that's it.
|
||||||
|
So to make it all work I need.
|
||||||
|
|
||||||
|
- a Gray theme,
|
||||||
|
- the package ~hl-sentence~,
|
||||||
|
- the ~writeroom~ package.
|
||||||
|
|
||||||
|
So how to achieve that yourself?
|
||||||
|
Here is how I do it.
|
||||||
|
|
||||||
|
** The zen-writer theme
|
||||||
|
:PROPERTIES:
|
||||||
|
:CUSTOM_ID: the-zen-writer-theme
|
||||||
|
:END:
|
||||||
|
|
||||||
|
Download [[./doom-zen-writer-theme.el][Doom Zen-Writer theme]].
|
||||||
|
This depend on doom-themes and here is the code of the theme.
|
||||||
|
Just put it in you =~/.doom.d/themes= directory.
|
||||||
|
|
||||||
|
** add this is your ~packages.el~
|
||||||
|
:PROPERTIES:
|
||||||
|
:CUSTOM_ID: add-this-is-your--packages-el-
|
||||||
|
:END:
|
||||||
|
|
||||||
|
#+begin_src elisp
|
||||||
|
(package! hl-sentence
|
||||||
|
:pin "86ae38d3103bd20da5485cbdd59dfbd396c45ee4")
|
||||||
|
#+end_src
|
||||||
|
** Helpers
|
||||||
|
:PROPERTIES:
|
||||||
|
:CUSTOM_ID: helpers
|
||||||
|
:END:
|
||||||
|
|
||||||
|
You probably want to be able to put you out of this writing mode.
|
||||||
|
Here is a [[file:zen-writer.el][zen-writer.el]] file that contain my keymaps and useful functions.
|
||||||
|
|
||||||
|
Put it in you =~/.doom.d/= directory and in you =config.el=
|
||||||
|
put
|
||||||
|
|
||||||
|
#+begin_src emacs-lisp
|
||||||
|
(load! "~/.doom.d/zen-writer.el")
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
And with this you should pass to zen mode with ~SPC y z z~.
|
||||||
|
|
||||||
|
To make the un-zen works.
|
||||||
|
You will need to have a ~y/auto-update-theme~ function that set your current theme.
|
||||||
|
My function change the theme depending on the time of the day or the day of
|
||||||
|
the week.
|
||||||
|
|
||||||
|
So here it is for inspiration:
|
||||||
|
|
||||||
|
#+begin_src emacs-lisp
|
||||||
|
(defun y/auto-update-theme ()
|
||||||
|
"depending on time use different theme"
|
||||||
|
;; very early => gruvbox-light, solarized-light, nord-light
|
||||||
|
(let* ((day-of-week (format-time-string "%a"))
|
||||||
|
(week-end? (or (equal "Sat" day-of-week)
|
||||||
|
(equal "Sun" day-of-week)))
|
||||||
|
(hour (nth 2 (decode-time (current-time))))
|
||||||
|
(time-to-sleep? (or (> hour 22) (< hour 7)))
|
||||||
|
|
||||||
|
(theme (cond
|
||||||
|
(time-to-sleep? 'doom-plain-dark)
|
||||||
|
(week-end? 'doom-nord-light)
|
||||||
|
((<= 7 hour 8) 'doom-gruvbox-light)
|
||||||
|
((= 9 hour) 'doom-solarized-light)
|
||||||
|
((<= 10 hour 16) 'doom-solarized-white)
|
||||||
|
((<= 17 hour 18) 'doom-gruvbox-light)
|
||||||
|
((<= 19 hour 22) 'doom-oceanic-next))))
|
||||||
|
(when (not (equal doom-theme theme))
|
||||||
|
(setq doom-theme theme)
|
||||||
|
(load-theme doom-theme t))
|
||||||
|
;; run that function again next hour
|
||||||
|
(run-at-time (format "%02d:%02d" (+ hour 1) 0) nil 'y/auto-update-theme)))
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
** Bonus
|
||||||
|
:PROPERTIES:
|
||||||
|
:CUSTOM_ID: bonus
|
||||||
|
:END:
|
||||||
|
|
||||||
|
I use Nerd Fonts and in particular the font `iMWritingDuoS` which is I
|
||||||
|
think a clone of the iAWriter font.
|
||||||
|
|
||||||
|
#+begin_src emacs-lisp
|
||||||
|
(setq doom-variable-pitch-font
|
||||||
|
(font-spec :family "iMWritingDuoS Nerd Font" :size 12))
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
I hope you find this useful.
|
||||||
|
I really like how it looks now.
|
||||||
|
|
||||||
|
** Annex
|
||||||
|
:PROPERTIES:
|
||||||
|
:CUSTOM_ID: annex
|
||||||
|
:END:
|
||||||
|
|
||||||
|
The code source used in this article.
|
||||||
|
|
||||||
|
*** zen-writer
|
||||||
|
:PROPERTIES:
|
||||||
|
:CUSTOM_ID: zen-writer
|
||||||
|
:END:
|
||||||
|
|
||||||
|
#+Name: zen-writer.el
|
||||||
|
#+begin_src emacs-lisp :tangle zen-writer.el
|
||||||
|
;;; zen-writer.el -*- lexical-binding: t; -*-
|
||||||
|
|
||||||
|
(defun y/zen ()
|
||||||
|
(interactive)
|
||||||
|
(setq doom-theme 'doom-zen-writer)
|
||||||
|
(load-theme doom-theme t)
|
||||||
|
(hl-sentence-mode +1))
|
||||||
|
|
||||||
|
(defun y/unzen ()
|
||||||
|
(interactive)
|
||||||
|
(y/auto-update-theme)
|
||||||
|
(hl-sentence-mode -1))
|
||||||
|
|
||||||
|
(defun y/zen-full ()
|
||||||
|
(interactive)
|
||||||
|
(y/zen)
|
||||||
|
(toggle-frame-fullscreen)
|
||||||
|
(doom-big-font-mode +1))
|
||||||
|
|
||||||
|
(defun y/unzen-full ()
|
||||||
|
(interactive)
|
||||||
|
(y/unzen)
|
||||||
|
(toggle-frame-fullscreen)
|
||||||
|
(doom-big-font-mode -1))
|
||||||
|
|
||||||
|
(map! :leader
|
||||||
|
(:prefix ("y z" . "Zen Writer")
|
||||||
|
:desc "Full Zen Writer" "z" #'y/zen-full
|
||||||
|
:desc "un-Full Zen Writer" "u" #'y/unzen-full
|
||||||
|
:desc "Zen Writer" "t" #'y/zen
|
||||||
|
:desc "un-Zen Writer" "q" #'y/unzen))
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
*** zen-writer doom theme
|
||||||
|
:PROPERTIES:
|
||||||
|
:CUSTOM_ID: zen-writer-doom-theme
|
||||||
|
:END:
|
||||||
|
|
||||||
|
#+begin_src emacs-lisp :tangle doom-zen-writer-theme.el
|
||||||
|
;;; doom-zen-writer-theme.el --- -*- lexical-binding: t; no-byte-compile: t; -*-
|
||||||
|
;;
|
||||||
|
;; Author: Yann Esposito <https://github.com/yogsototh>
|
||||||
|
;; Created: October 24, 2021
|
||||||
|
;; Version: 1.0.0
|
||||||
|
;; Keywords: custom themes, faces
|
||||||
|
;; Homepage: https://github.com/hlissner/emacs-doom-themes
|
||||||
|
;; Package-Requires: ((emacs "25.1") (cl-lib "0.5") (doom-themes "2.2.1"))
|
||||||
|
;;
|
||||||
|
;;; Code:
|
||||||
|
|
||||||
|
(require 'doom-themes)
|
||||||
|
|
||||||
|
;;
|
||||||
|
;;; Variables
|
||||||
|
|
||||||
|
(defgroup doom-plain-theme nil
|
||||||
|
"Options for the `doom-plain' theme."
|
||||||
|
:group 'doom-themes)
|
||||||
|
|
||||||
|
(defcustom doom-plain-padded-modeline doom-themes-padded-modeline
|
||||||
|
"If non-nil, adds a 4px padding to the mode-line.
|
||||||
|
Can be an integer to determine the exact padding."
|
||||||
|
:group 'doom-plain-theme
|
||||||
|
:type '(or integer boolean))
|
||||||
|
|
||||||
|
|
||||||
|
;;
|
||||||
|
;;; Theme definition
|
||||||
|
|
||||||
|
(def-doom-theme doom-zen-writer
|
||||||
|
"Theme inspired by gko's plain."
|
||||||
|
|
||||||
|
;; name default/256/16
|
||||||
|
((bg '("#ffffff"))
|
||||||
|
(bg-alt '("#eaecea"))
|
||||||
|
(base0 '("#969896"))
|
||||||
|
(base1 '("#f1f3f5"))
|
||||||
|
(base2 '("#606666"))
|
||||||
|
(base3 '("#cccccc"))
|
||||||
|
(base4 '("#e7e7e7"))
|
||||||
|
(base5 '("#a5a8a6"))
|
||||||
|
(base6 '("#fafafa"))
|
||||||
|
(base7 '("#dfdfdf"))
|
||||||
|
(base8 '("#fafafa"))
|
||||||
|
(fg '("#969896"))
|
||||||
|
(fg-alt (doom-lighten fg 0.15))
|
||||||
|
|
||||||
|
(grey fg)
|
||||||
|
(red fg)
|
||||||
|
(blue fg)
|
||||||
|
(dark-blue fg)
|
||||||
|
(orange fg)
|
||||||
|
(green fg)
|
||||||
|
(teal fg)
|
||||||
|
(yellow fg)
|
||||||
|
(magenta fg)
|
||||||
|
(violet fg)
|
||||||
|
(cyan fg)
|
||||||
|
(dark-cyan fg)
|
||||||
|
|
||||||
|
;; face categories -- required for all themes
|
||||||
|
(highlight base2)
|
||||||
|
(vertical-bar base5)
|
||||||
|
(selection base1)
|
||||||
|
(builtin base0)
|
||||||
|
(comments base5)
|
||||||
|
(doc-comments base5)
|
||||||
|
(constants base0)
|
||||||
|
(functions fg)
|
||||||
|
(keywords fg)
|
||||||
|
(methods fg)
|
||||||
|
(operators fg)
|
||||||
|
(type fg)
|
||||||
|
(strings base0)
|
||||||
|
(variables base0)
|
||||||
|
(numbers base0)
|
||||||
|
(region base4)
|
||||||
|
(error (doom-blend fg "#ff0000" 0.4))
|
||||||
|
(warning base2)
|
||||||
|
(success green)
|
||||||
|
(vc-modified base5)
|
||||||
|
(vc-added (doom-lighten fg 0.7))
|
||||||
|
(vc-deleted base2)
|
||||||
|
|
||||||
|
;; custom categories
|
||||||
|
(-modeline-pad
|
||||||
|
(when doom-plain-padded-modeline
|
||||||
|
(if (integerp doom-plain-padded-modeline) doom-plain-padded-modeline 4)))
|
||||||
|
|
||||||
|
(modeline-bg (doom-darken bg-alt 0.15))
|
||||||
|
(modeline-bg-alt (doom-darken bg-alt 0.1))
|
||||||
|
(modeline-bg-inactive (doom-darken bg-alt 0.1))
|
||||||
|
(modeline-bg-inactive-alt bg-alt)
|
||||||
|
(modeline-fg fg)
|
||||||
|
(modeline-fg-alt (doom-darken modeline-bg-inactive 0.35)))
|
||||||
|
|
||||||
|
;;;; Base theme face overrides
|
||||||
|
((error :underline `(:style wave :color ,error))
|
||||||
|
(warning :underline `(:style wave :color ,warning))
|
||||||
|
(hl-sentence :foreground "#000000" :background bg)
|
||||||
|
((font-lock-constant-face &override) :slant 'italic)
|
||||||
|
((font-lock-comment-face &override) :slant 'italic)
|
||||||
|
((font-lock-function-name-face &override) :slant 'italic)
|
||||||
|
((font-lock-type-face &override) :slant 'italic)
|
||||||
|
(hl-line :background base8)
|
||||||
|
((line-number &override) :foreground base3)
|
||||||
|
((line-number-current-line &override) :foreground base2)
|
||||||
|
(mode-line
|
||||||
|
:background modeline-bg :foreground modeline-fg
|
||||||
|
:box (if -modeline-pad `(:line-width ,-modeline-pad :color ,modeline-bg)))
|
||||||
|
(mode-line-inactive
|
||||||
|
:background modeline-bg-inactive :foreground modeline-fg-alt
|
||||||
|
:box (if -modeline-pad `(:line-width ,-modeline-pad :color ,modeline-bg-inactive)))
|
||||||
|
(mode-line-emphasis :foreground highlight)
|
||||||
|
|
||||||
|
;;;; doom-modeline
|
||||||
|
(doom-modeline-bar :background modeline-bg)
|
||||||
|
(doom-modeline-bar-inactive :inherit 'doom-modeline-bar)
|
||||||
|
(doom-modeline-project-dir :foreground fg)
|
||||||
|
(doom-modeline-buffer-file :foreground fg)
|
||||||
|
(doom-modeline-buffer-modified :weight 'bold :foreground "#000000")
|
||||||
|
(doom-modeline-panel :inherit 'mode-line-highlight :background base3 :foreground fg)
|
||||||
|
;;;; ivy
|
||||||
|
(ivy-posframe :background bg-alt)
|
||||||
|
;;;; magit
|
||||||
|
((magit-diff-added-highlight &override) :foreground fg :background (doom-blend vc-added bg 0.3))
|
||||||
|
((magit-diff-removed &override) :foreground (doom-lighten fg 0.4) :background (doom-blend vc-deleted bg 0.1))
|
||||||
|
((magit-diff-removed-highlight &override) :foreground fg :background (doom-blend vc-deleted bg 0.22))
|
||||||
|
;;;; lsp-mode
|
||||||
|
(lsp-headerline-breadcrumb-symbols-face :foreground keywords :weight 'bold)
|
||||||
|
;;;; outline <built-in>
|
||||||
|
(outline-1 :slant 'italic :foreground fg-alt)
|
||||||
|
(outline-2 :inherit 'outline-1 :foreground base2)
|
||||||
|
(outline-3 :inherit 'outline-2)
|
||||||
|
(outline-4 :inherit 'outline-3)
|
||||||
|
(outline-5 :inherit 'outline-4)
|
||||||
|
(outline-6 :inherit 'outline-5)
|
||||||
|
(outline-7 :inherit 'outline-6)
|
||||||
|
(outline-8 :inherit 'outline-7)
|
||||||
|
;;;; org <built-in>
|
||||||
|
((org-block &override) :background bg-alt)
|
||||||
|
((org-block-begin-line &override) :foreground base5)
|
||||||
|
;;;; solaire-mode
|
||||||
|
(solaire-mode-line-face
|
||||||
|
:inherit 'mode-line
|
||||||
|
:background modeline-bg-alt
|
||||||
|
:box (if -modeline-pad `(:line-width ,-modeline-pad :color ,modeline-bg-alt)))
|
||||||
|
(solaire-mode-line-inactive-face
|
||||||
|
:inherit 'mode-line-inactive
|
||||||
|
:background modeline-bg-inactive-alt
|
||||||
|
:box (if -modeline-pad `(:line-width ,-modeline-pad :color ,modeline-bg-inactive-alt)))))
|
||||||
|
|
||||||
|
;;; doom-zen-writer-theme.el ends here
|
||||||
|
#+end_src
|
Binary file not shown.
|
@ -0,0 +1,31 @@
|
||||||
|
;;; zen-writer.el -*- lexical-binding: t; -*-
|
||||||
|
|
||||||
|
(defun y/zen ()
|
||||||
|
(interactive)
|
||||||
|
(setq doom-theme 'doom-zen-writer)
|
||||||
|
(load-theme doom-theme t)
|
||||||
|
(hl-sentence-mode +1))
|
||||||
|
|
||||||
|
(defun y/unzen ()
|
||||||
|
(interactive)
|
||||||
|
(y/auto-update-theme)
|
||||||
|
(hl-sentence-mode -1))
|
||||||
|
|
||||||
|
(defun y/zen-full ()
|
||||||
|
(interactive)
|
||||||
|
(y/zen)
|
||||||
|
(toggle-frame-fullscreen)
|
||||||
|
(doom-big-font-mode +1))
|
||||||
|
|
||||||
|
(defun y/unzen-full ()
|
||||||
|
(interactive)
|
||||||
|
(y/unzen)
|
||||||
|
(toggle-frame-fullscreen)
|
||||||
|
(doom-big-font-mode -1))
|
||||||
|
|
||||||
|
(map! :leader
|
||||||
|
(:prefix ("y z" . "Zen Writer")
|
||||||
|
:desc "Full Zen Writer" "z" #'y/zen-full
|
||||||
|
:desc "un-Full Zen Writer" "u" #'y/unzen-full
|
||||||
|
:desc "Zen Writer" "t" #'y/zen
|
||||||
|
:desc "un-Zen Writer" "q" #'y/unzen))
|
204
src/posts/0021-my-personal-environment-sync/index.org
Normal file
204
src/posts/0021-my-personal-environment-sync/index.org
Normal file
|
@ -0,0 +1,204 @@
|
||||||
|
#+title: My personal environment sync
|
||||||
|
#+description:
|
||||||
|
#+keywords: programming
|
||||||
|
#+author: Yann Esposito
|
||||||
|
#+email: yann@esposito.host
|
||||||
|
#+date: [2021-10-30 Sat]
|
||||||
|
#+lang: en
|
||||||
|
#+options: auto-id:t
|
||||||
|
#+startup: showeverything
|
||||||
|
|
||||||
|
I have a quite specific system that I improved along the years to manage my
|
||||||
|
local environment.
|
||||||
|
Think about, binaries I expect to have in my shell, as well as
|
||||||
|
configuration files for various utilities, and a few personal scripts.
|
||||||
|
|
||||||
|
The notion of what is exactly my local environment is not perfectly defined.
|
||||||
|
I expect every of my computers to behave slightly differently.
|
||||||
|
Some are for work-only, some personal use only.
|
||||||
|
|
||||||
|
For the things I want everywhere, I have a peculiar personal system.
|
||||||
|
|
||||||
|
I use a personal script that depends on [[https://yadm.io][yadm]] and [[https://github.com/nix-community/home-manager][home-manager]].
|
||||||
|
|
||||||
|
My script try to check if some files where updated and react accordingly:
|
||||||
|
|
||||||
|
1. I download the dot-files changes via =yadm=.
|
||||||
|
2. If my home-manager files changes, it will run ~home-manager switch~
|
||||||
|
; if it fails, try to update nix channels then try again.
|
||||||
|
3. If my doom emacs packages changed, it will run ~doom sync~
|
||||||
|
4. If the script itself changed, it re-run the script after updating itself.
|
||||||
|
|
||||||
|
If the script detect that I changed my emacs configuration, it runs ~doom
|
||||||
|
sync~ or ~doom sync -u~.
|
||||||
|
|
||||||
|
Here it is:
|
||||||
|
|
||||||
|
#+begin_src bash
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
### logs fn helpers
|
||||||
|
|
||||||
|
## colors for tput
|
||||||
|
# black=0
|
||||||
|
red=1
|
||||||
|
green=2
|
||||||
|
yellow=3
|
||||||
|
blue=4
|
||||||
|
# magenta=5
|
||||||
|
# cyan=6
|
||||||
|
# white=7
|
||||||
|
highpr() {
|
||||||
|
printf "$(tput setaf $green)→$(tput sgr0) $(tput bold)%-60s$(tput sgr0)" "$*"
|
||||||
|
}
|
||||||
|
ok() {
|
||||||
|
local txt="OK"
|
||||||
|
echo -e " [$(tput bold)$(tput setaf $green)${txt}$(tput sgr0)]" >&2
|
||||||
|
}
|
||||||
|
info() {
|
||||||
|
echo -e " [$(tput bold)$(tput setaf $blue)$*$(tput sgr0)]" >&2
|
||||||
|
}
|
||||||
|
warn() {
|
||||||
|
echo -e "$(tput bold)$(tput setaf $yellow)$*$(tput sgr0)" >&2
|
||||||
|
}
|
||||||
|
err() {
|
||||||
|
echo -e "$(tput bold)$(tput setaf $red)$*$(tput sgr0)" >&2
|
||||||
|
}
|
||||||
|
fail() {
|
||||||
|
err -e "\n[ERR] $*"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
highpr "check nix"
|
||||||
|
if ! [ -x "$(command -v nix)" ]; then
|
||||||
|
echo
|
||||||
|
err "nix does not seem to be installed."
|
||||||
|
err "Install it from: https://nixos.org/nix/"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
ok
|
||||||
|
|
||||||
|
highpr "yadm fetch"
|
||||||
|
yadm fetch --quiet || fail "yadm fetch failed"
|
||||||
|
ok
|
||||||
|
|
||||||
|
# check the hash of a few files before doing yadm pull
|
||||||
|
OLD_SYNC_ENV_ID=$(yadm rev-parse HEAD:bin/sync-env.sh)
|
||||||
|
OLD_HOME_MANAGER_ID=$(yadm rev-parse HEAD:.config/nixpkgs/home.nix)
|
||||||
|
OLD_DOOM_PACKAGES=$(yadm rev-parse HEAD:.doom.d/packages.el)
|
||||||
|
OLD_DOOM_INIT=$(yadm rev-parse HEAD:.doom.d/init.el)
|
||||||
|
|
||||||
|
highpr "yadm pull"
|
||||||
|
yadm pull --quiet || fail "yadm pull failed"
|
||||||
|
ok
|
||||||
|
|
||||||
|
# check the hash of a few files after doing yadm pull
|
||||||
|
NEW_SYNC_ENV_ID=$(yadm rev-parse HEAD:bin/sync-env.sh)
|
||||||
|
NEW_HOME_MANAGER_ID=$(yadm rev-parse HEAD:.config/nixpkgs/home.nix)
|
||||||
|
NEW_DOOM_PACKAGES=$(yadm rev-parse HEAD:.doom.d/packages.el)
|
||||||
|
NEW_DOOM_INIT=$(yadm rev-parse HEAD:.doom.d/init.el)
|
||||||
|
|
||||||
|
highpr "check sync-env diff"
|
||||||
|
if ! [ "$OLD_SYNC_ENV_ID" = "$NEW_SYNC_ENV_ID" ]; then
|
||||||
|
warn " changed"
|
||||||
|
warn " Starting ~/bin/sync-env.sh again"
|
||||||
|
echo
|
||||||
|
~/bin/sync-env.sh
|
||||||
|
exit $?
|
||||||
|
fi
|
||||||
|
ok
|
||||||
|
|
||||||
|
if [ -f "$HOME/.yadm/files.gpg" ]; then
|
||||||
|
highpr "yadm decrypt"
|
||||||
|
yadm decrypt || fail "yadm decrypt failed"
|
||||||
|
ok
|
||||||
|
fi
|
||||||
|
|
||||||
|
highpr "home-manager"
|
||||||
|
USERNAME_NIX_FILE="$HOME/.config/nixpkgs/username.nix"
|
||||||
|
if [ ! -f "$USERNAME_NIX_FILE" ]; then
|
||||||
|
echo "\"$USER\"" >> "$USERNAME_NIX_FILE"
|
||||||
|
fi
|
||||||
|
if ! [ "$OLD_HOME_MANAGER_ID" = "$NEW_HOME_MANAGER_ID" ]; then
|
||||||
|
echo
|
||||||
|
highpr "home-manager switch"
|
||||||
|
home-manager switch || \
|
||||||
|
( nix-channel --update && home-manager switch ) || \
|
||||||
|
fail "home-manager switch failed"
|
||||||
|
ok
|
||||||
|
else
|
||||||
|
info "skipped"
|
||||||
|
fi
|
||||||
|
|
||||||
|
highpr "doom-emacs"
|
||||||
|
doompath="$HOME/.emacs.d/bin/doom"
|
||||||
|
if ! [ "$OLD_DOOM_PACKAGES" = "$NEW_DOOM_PACKAGES" ] || \
|
||||||
|
! [ "$OLD_DOOM_INIT" = "$NEW_DOOM_INIT" ]; then
|
||||||
|
if [[ -x $doompath ]]; then
|
||||||
|
echo
|
||||||
|
highpr "doom sync"
|
||||||
|
$doompath sync || fail "doom failed to sync"
|
||||||
|
ok
|
||||||
|
else
|
||||||
|
fail "Cannot find doom executable at $doompath";
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
info "skipped"
|
||||||
|
fi
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
** Bootstrapping
|
||||||
|
:PROPERTIES:
|
||||||
|
:CUSTOM_ID: boostraping
|
||||||
|
:END:
|
||||||
|
|
||||||
|
Bootstrapping this system is always a nice problem to think about.
|
||||||
|
It is smooth when everything is set but to bootstrap it I need binaries
|
||||||
|
installed by this system...
|
||||||
|
So...
|
||||||
|
How to handle the dependency cycle correctly?
|
||||||
|
|
||||||
|
To minimize the pain, I removed more and more bootstrapping dependencies.
|
||||||
|
Now my almost single dependence for bootstrapping my environment is =nix=.
|
||||||
|
I haven't initialized any machine for a long time now.
|
||||||
|
The following should work.
|
||||||
|
|
||||||
|
0. Use fish[fn:fish] ~chsh /bin/fish~
|
||||||
|
1. Install nix
|
||||||
|
~curl -L https://nixos.org/nix/install | sh~
|
||||||
|
2. Install home-manager
|
||||||
|
#+begin_src bash
|
||||||
|
nix-channel --add https://github.com/nix-community/home-manager/archive/release-21.05.tar.gz home-manager
|
||||||
|
nix-channel --update
|
||||||
|
export NIX_PATH=$HOME/.nix-defexpr/channels${NIX_PATH:+:}$NIX_PATH
|
||||||
|
nix-shell '<home-manager>' -A install
|
||||||
|
#+end_src
|
||||||
|
3. Install and use ~yadm~
|
||||||
|
#+begin_src bash
|
||||||
|
nix-shell -p yadm
|
||||||
|
yadm boostrap
|
||||||
|
yadm remote set-url origin <url-to-my-dot-files-repo>
|
||||||
|
yadm pull
|
||||||
|
#+end_src
|
||||||
|
4. Still in the =nix-shell= with =yadm= run ~~/bin/sync-env.sh~
|
||||||
|
|
||||||
|
|
||||||
|
There is a risk that step 3 fail because I pin most of my packages in
|
||||||
|
home-manager configuration, and it will try to install =yadm=. This can
|
||||||
|
conflict with the =yadm= installed in the current =nix-shell=.
|
||||||
|
So sometime I need to:
|
||||||
|
|
||||||
|
1. Remove the line installing =yadm= in my home-manager configuration first
|
||||||
|
2. run =home-manager sync=
|
||||||
|
3. get out of the =nix-shell=,
|
||||||
|
4. add =yadm= back in the =home-manager= config
|
||||||
|
5. run =home-manager sync= again, but this time out of the =nix-shell=.
|
||||||
|
6. Finally I can run my =~/bin/sync-env.sh= command.
|
||||||
|
|
||||||
|
So this post will probably be useful as a personal note in the future.
|
||||||
|
Because bootstrapping is generally not trivial.
|
||||||
|
I will probably update this post if something is missing.
|
||||||
|
|
||||||
|
[fn:fish] I use fish for interactive shell. I use ~zsh~ for quick dirty
|
||||||
|
scripts (a lot better than bash), and I switch to [[https://hackage.haskell.org/package/turtle][turtle]] if I need to be
|
||||||
|
serious about the script.
|
Loading…
Reference in a new issue