dynamic tangling based on tags

master
Jacopo De Simoi 5 years ago
parent 1e42bbf8c6
commit 90af7e090f
  1. 64
      zshrc.org

@ -12,6 +12,7 @@ All posts in here will have the category set to /zsh/.
:EXPORT_FILE_NAME: zshrc-file
:EXPORT_DATE: 2020-08-05
:EXPORT_HUGO_MENU: :menu "main"
:header-args: :tangle (org-tags-to-filenames)
:END:
This is my ~.zshrc~; it will be used in many environments:
- daily driver (gentoo box with kde)
@ -20,12 +21,29 @@ This is my ~.zshrc~; it will be used in many environments:
- raspberry pi
- mips box
Each environment has slightly different setups, which will be tangled to different files
Each environment has slightly different setups, which will be tangled
to different files according to the function `org-tags-to-filenames',
which checks the tags of the current headline and returns a list of
corresponding filenames. For instance if the tags are daily and pi,
the function returns '(".zshrc" ".zshrc.pi")
#+name:def-tag
#+begin_src emacs-lisp :results output silent
(setq tag-to-filenames-alist '(("daily" . ".zshrc")
("pi" . ".zshrc.pi")))
(defun org-tags-to-filenames ()
(remove nil (mapcar
(lambda (tag)
(cdr (assoc tag tag-to-filenames-alist)))
(org-split-string (car (last (org-heading-components))) ":"))))
#+end_src
*** Include :daily:pi:
*** Include :daily:pi:android:
First, include a script that sets a number of confidential data (e.g. API keys and such)
#+BEGIN_SRC sh :tangle ".zshrc"
#+BEGIN_SRC sh
source ~/.config/confidential.sh
# This defines a number of env variables:
# ANDROID_A3=xxxx
@ -34,7 +52,7 @@ Each environment has slightly different setups, which will be tangled to differe
# ifttt_apikey=xyz
#+end_src
Then, add helper directory to fpath
#+begin_src sh :tangle ".zshrc"
#+begin_src sh
fpath=(~/clones/zshrc/ $fpath)
#+end_src
@ -46,7 +64,7 @@ Each environment has slightly different setups, which will be tangled to differe
The other two swap between build and src dirs on my local git checkout
#+BEGIN_SRC sh :tangle ".zshrc"
#+BEGIN_SRC sh
kde-current-activity () {
qdbus org.kde.ActivityManager /ActivityManager/Activities org.kde.ActivityManager.Activities.CurrentActivity
}
@ -80,7 +98,7 @@ The other two swap between build and src dirs on my local git checkout
These are various helpers to drive my current Android phone when connected to the box.
#+begin_src sh :tangle ".zshrc"
#+begin_src sh
run-task () {
adb shell am broadcast --user 0 -a net.dinglish.tasker.run_task -e task "$1"
@ -131,10 +149,10 @@ setup-pi-webcam()
:CREATED: [2021-05-01 Sat 10:35]
:END:
*** Misc helpers
*** Misc helpers :pi:daily:android:
- wttr.in
#+begin_src sh :tangle '(".zshrc" ".zshrc.pi" ".zshrc.android")
#+begin_src sh
wttr()
{
local location=Toronto
@ -166,11 +184,11 @@ setup-pi-webcam()
_ifttt
#+end_src
Load the function
#+begin_src shell :tangle '(".zshrc" ".zshrc.pi")
#+begin_src sh
autoload ifttt
#+end_src
*** konsole helpers
#+begin_src sh :tangle ".zshrc"
*** konsole helpers :daily:
#+begin_src sh
function set-terminal-title() {
echo -en "\e]2;$@\a"
}
@ -193,9 +211,9 @@ setup-pi-webcam()
}
#+end_src
*** emacs helpers
*** emacs helpers :daily:
#+begin_src sh :tangle ".zshrc"
#+begin_src sh
SOLARIZED="true"
export EMACS="/home/jacopods/.emacs.d/emacsclient-activities"
@ -226,8 +244,8 @@ setup-pi-webcam()
}
#+end_src
*** oh-my-zsh setup
#+begin_src sh :tangle '(".zshrc" ".zshrc.pi" ".zshrc.android")
*** oh-my-zsh setup :daily:pi:android:
#+begin_src sh
# Path to your oh-my-zsh configuration.
ZSH=$HOME/.oh-my-zsh
@ -330,9 +348,9 @@ setup-pi-webcam()
autoload zmv
#+end_src
*** TODO editor env variables
*** TODO editor env variables :daily:
This needs to be diff'd among the versions
#+begin_src sh :tangle ".zshrc"
#+begin_src sh
# editor stuff
@ -341,8 +359,8 @@ setup-pi-webcam()
export GIT_EDITOR=$EMACS
export SUDO_EDITOR=$EMACS
#+end_src
*** git helpers
#+begin_src sh :tangle ".zshrc"
*** git helpers :daily:
#+begin_src sh
git-create-pi-remote () {
REPO_NAME=$(basename "`pwd`")
source ~/scripts/git-init-pi4.sh "$REPO_NAME.git"
@ -365,9 +383,9 @@ setup-pi-webcam()
:CREATED: [2021-05-01 Sat 16:26]
:END:
*** Aliases
*** Aliases :pi:android:daily:
#+begin_src sh :tangle ".zshrc"
#+begin_src sh
## Aliases
@ -386,9 +404,9 @@ setup-pi-webcam()
alias xou="source /home/jacopods/scripts/setwacom.sh;/home/jacopods/clones/xournalpp/build/src/xournalpp"
#+end_src
*** Pomodoro helpers
*** Pomodoro helpers :daily:pi:android:
#+begin_src sh :tangle ".zshrc"
#+begin_src sh
termdown_bin=/home/jacopods/.local/bin/termdown
alias pomo="$termdown_bin 25m -aW -f 3x5 -c 180 -b -q 10 -s $@"

Loading…
Cancel
Save