From f5e07059df2e98f1f507e0b4ddb7a649a156a0c1 Mon Sep 17 00:00:00 2001 From: fpi Date: Mon, 13 Jan 2020 15:27:54 +0100 Subject: Add README --- README.org | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 README.org (limited to 'README.org') diff --git a/README.org b/README.org new file mode 100644 index 0000000..bfd2a0d --- /dev/null +++ b/README.org @@ -0,0 +1,17 @@ +* My dotfiles +The config files are organized in emacs org files. They are tangled +and symlinked to the appropriate directories. + +[[file:emacs-init.org::*tangle%20dotfiles][A hook]] tangles all files automatically on each save. +~emacs-init.org~ is special and not automatically tangled. The >100 src +blocks make tangling take several seconds and ~org-babel-load-file~ in +~init.el~ tangles the init org file on each emacs start anyway. + +For now the symlinks need to be created by manually running the +appropriate src block in each configuration file. + +* Window manager +I use [[https://github.com/ch11ng/exwm][exwm]] and [[https://awesomewm.org/][awesome]] as my window managers. When doing a lot of +coding and similar stuff I tend to use exwm as I will spend most of my +time in emacs anyway. + -- cgit v1.2.3 From fc2267fb8857a0af0dd63d683756a7f839834665 Mon Sep 17 00:00:00 2001 From: fpi Date: Sun, 2 Feb 2020 15:40:19 +0100 Subject: Add git merge script --- README.org | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'README.org') diff --git a/README.org b/README.org index bfd2a0d..03ac014 100644 --- a/README.org +++ b/README.org @@ -10,6 +10,18 @@ blocks make tangling take several seconds and ~org-babel-load-file~ in For now the symlinks need to be created by manually running the appropriate src block in each configuration file. +** Git Setup +Every program's configuration lives in its own branch. All branches +are then merged into =master=. To keep the git history clean, I use +this script: + +#+begin_src shell :shebang "#!/bin/bash" :tangle tangle/merge.sh +git checkout master +git reset --hard init +git branch | grep -v private | sed "s/[ *] //" | xargs git merge +git push --force origin master +#+end_src + * Window manager I use [[https://github.com/ch11ng/exwm][exwm]] and [[https://awesomewm.org/][awesome]] as my window managers. When doing a lot of coding and similar stuff I tend to use exwm as I will spend most of my -- cgit v1.2.3 From 5bf8101f2a6f7ca60e09558b08430afc085d2044 Mon Sep 17 00:00:00 2001 From: fpi Date: Sun, 23 Feb 2020 18:40:09 +0100 Subject: Exclude branches which match +$ in merge script --- README.org | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'README.org') diff --git a/README.org b/README.org index 03ac014..929e139 100644 --- a/README.org +++ b/README.org @@ -12,13 +12,13 @@ appropriate src block in each configuration file. ** Git Setup Every program's configuration lives in its own branch. All branches -are then merged into =master=. To keep the git history clean, I use -this script: +except the ones which end with a plus sign are then merged into +=master=. To keep the git history clean, I use this script: #+begin_src shell :shebang "#!/bin/bash" :tangle tangle/merge.sh git checkout master git reset --hard init -git branch | grep -v private | sed "s/[ *] //" | xargs git merge +git branch | grep -v -e +$ -e master | sed "s/[ *] //" | xargs git merge git push --force origin master #+end_src -- cgit v1.2.3 From 699c269abaf109e4f997e50e68a76e0454f5cdf1 Mon Sep 17 00:00:00 2001 From: fpi Date: Sun, 23 Feb 2020 18:43:50 +0100 Subject: Include remote branches in the merge script --- README.org | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'README.org') diff --git a/README.org b/README.org index 929e139..0877cc1 100644 --- a/README.org +++ b/README.org @@ -18,7 +18,7 @@ except the ones which end with a plus sign are then merged into #+begin_src shell :shebang "#!/bin/bash" :tangle tangle/merge.sh git checkout master git reset --hard init -git branch | grep -v -e +$ -e master | sed "s/[ *] //" | xargs git merge +git branch -a | grep -v -e +$ -e master | sed "s/[ *] //" | xargs git merge git push --force origin master #+end_src -- cgit v1.2.3 From 60015f844b659b456b44eedc540a8106a1d1018f Mon Sep 17 00:00:00 2001 From: fpi Date: Sun, 5 Apr 2020 19:00:52 +0200 Subject: Add script to (re-)tangle all files --- README.org | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) (limited to 'README.org') diff --git a/README.org b/README.org index 0877cc1..3355f7d 100644 --- a/README.org +++ b/README.org @@ -22,8 +22,42 @@ git branch -a | grep -v -e +$ -e master | sed "s/[ *] //" | xargs git merge git push --force origin master #+end_src +** Updating all tangled files +This script (re-)tangles all =.org= and =.org.gpg= files. Run this in +case the org files were updated outside of your local emacs (e.g. +after pulling from a remote). Make sure to run it from the dotfiles +directory. + +#+begin_src shell :shebang "#!/bin/bash" :tangle no +emacs --batch --eval="\ + (progn (require 'org) + (let ((org-confirm-babel-evaluate nil)) + (mapc 'org-babel-tangle-file (split-string \"$(ls *.org *.org.gpg)\"))))" +#+end_src + +The above won't quite work for me as I use ~org-crypt~ in some +configuration files and it also needs to be loaded & setup. For +details see [[file:emacs-init.org][emacs-init.org]]. + +#+begin_src shell :shebang "#!/bin/bash" :tangle tangle/tangle.sh +emacs --batch --eval="\ + (progn (require 'org) + (require 'org-crypt) + (org-crypt-use-before-save-magic) + (setq org-tags-exclude-from-inheritance '(\"crypt\")) + (setq org-crypt-key \"F1EF502F9E81D81381B1679AF973BBEA6994521B\") + (defun save-without-hook () + (let ((before-save-hook nil)) + (save-buffer))) + (setq org-babel-pre-tangle-hook '(org-decrypt-entries save-without-hook)) + (advice-add 'org-babel-tangle :after '(lambda (&rest r) + (org-encrypt-entries) + (save-without-hook))) + (let ((org-confirm-babel-evaluate nil)) + (mapc 'org-babel-tangle-file (split-string \"$(ls *.org *.org.gpg)\"))))" +#+end_src + * Window manager I use [[https://github.com/ch11ng/exwm][exwm]] and [[https://awesomewm.org/][awesome]] as my window managers. When doing a lot of coding and similar stuff I tend to use exwm as I will spend most of my time in emacs anyway. - -- cgit v1.2.3 From 20402088679d2fd52052dad73b15739f178d5819 Mon Sep 17 00:00:00 2001 From: fpi Date: Sun, 5 Apr 2020 19:59:31 +0200 Subject: Add script to create all symlinks --- README.org | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) (limited to 'README.org') diff --git a/README.org b/README.org index 3355f7d..477de5f 100644 --- a/README.org +++ b/README.org @@ -7,8 +7,8 @@ and symlinked to the appropriate directories. blocks make tangling take several seconds and ~org-babel-load-file~ in ~init.el~ tangles the init org file on each emacs start anyway. -For now the symlinks need to be created by manually running the -appropriate src block in each configuration file. +The symlinks can be created by manually running the appropriate src +block in each configuration file. For an automated solution see below. ** Git Setup Every program's configuration lives in its own branch. All branches @@ -57,6 +57,39 @@ emacs --batch --eval="\ (mapc 'org-babel-tangle-file (split-string \"$(ls *.org *.org.gpg)\"))))" #+end_src +** Creating symlinks +Each config files contains a source block which creates symlinks of +the tangled configurations to their respective target locations. These +blocks all have the ~:tangle tangle/symlink.sh~ and ~:shebang +#!/bin/bash~ header arguments. The symlinks are created with ~ln -siv~ +to list created symlinks (~-v~) and to ask when overwriting existing +files (~-i~). To always replace all symlinks you can pipe ~yes~ into +the ~ln -siv~ calls: ~yes | tangle/link.sh~. Make sure to run it from +the dotfiles directory. + +As the symlink shell source blocks are scattered in all configuration +files, all files are collected together using cat and then all blocks +with the correct ~:tangle~ target are tangled. Unfortunately there is +no function to directly only tangle blocks with a certain target, so +this is not straightforward. +#+begin_src shell :shebang "#!/bin/bash" :tangle tangle/link.sh +catFile="concat.org" +symlinkFile="tangle/symlink.sh" + +cat <(cat *.org) <(ls *.org.gpg | xargs gpg --decrypt) > $catFile + +emacs --batch --eval="\ + (progn (require 'org) + (let ((org-confirm-babel-evaluate nil)) + (find-file \"$catFile\") + (search-forward \":tangle $symlinkFile\") + (org-babel-tangle '(16))))" + +rm $catFile + +$symlinkFile +#+end_src + * Window manager I use [[https://github.com/ch11ng/exwm][exwm]] and [[https://awesomewm.org/][awesome]] as my window managers. When doing a lot of coding and similar stuff I tend to use exwm as I will spend most of my -- cgit v1.2.3 From a6ac92abcbc0bdf3e55470071defcc6f7529ee94 Mon Sep 17 00:00:00 2001 From: fpi Date: Sun, 5 Apr 2020 20:55:51 +0200 Subject: Remove note of not tangling emacs-init.org This already changed a while back. See commits in the ~emacs~ branch. Tangling on emacs startup was unnecessarily slow. --- README.org | 3 --- 1 file changed, 3 deletions(-) (limited to 'README.org') diff --git a/README.org b/README.org index 477de5f..0020720 100644 --- a/README.org +++ b/README.org @@ -3,9 +3,6 @@ The config files are organized in emacs org files. They are tangled and symlinked to the appropriate directories. [[file:emacs-init.org::*tangle%20dotfiles][A hook]] tangles all files automatically on each save. -~emacs-init.org~ is special and not automatically tangled. The >100 src -blocks make tangling take several seconds and ~org-babel-load-file~ in -~init.el~ tangles the init org file on each emacs start anyway. The symlinks can be created by manually running the appropriate src block in each configuration file. For an automated solution see below. -- cgit v1.2.3 From ffb23cc69641171ede39d798032b631e513fd4de Mon Sep 17 00:00:00 2001 From: fpi Date: Fri, 12 Jun 2020 15:05:55 +0200 Subject: Update readme to more accurately reflect status quo --- README.org | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) (limited to 'README.org') diff --git a/README.org b/README.org index 0020720..34ca2b7 100644 --- a/README.org +++ b/README.org @@ -1,16 +1,22 @@ * My dotfiles -The config files are organized in emacs org files. They are tangled +The config files are organized in [[https://www.gnu.org/software/emacs/][emacs]] [[https://orgmode.org/][org mode]] files. They are tangled and symlinked to the appropriate directories. -[[file:emacs-init.org::*tangle%20dotfiles][A hook]] tangles all files automatically on each save. +[[file:emacs-init.org::tangle-hook][A hook]] tangles all files automatically on each save. In addition there +are shell scripts that tangle all =.org= files at once. -The symlinks can be created by manually running the appropriate src -block in each configuration file. For an automated solution see below. +The symlinks can be created by manually running the appropriate [[https://orgmode.org/worg/org-contrib/babel/][babel]] +source block in each configuration file or by running the scripts +below. ** Git Setup -Every program's configuration lives in its own branch. All branches -except the ones which end with a plus sign are then merged into -=master=. To keep the git history clean, I use this script: +This repository somewhat abuses git branches. Every program's +configuration lives in its own separate branch. All branches are then +merged into =master= using an [[https://git-scm.com/docs/merge-strategies#Documentation/merge-strategies.txt-octopus][octopus merge]]. To keep the git history +clean I reset =master= for every merge. Here is a small script to do +that and push the changes. I mark branches, which I want to keep local +only, with a trailing =+= and then exclude them with the ~+$~ pattern +in grep. #+begin_src shell :shebang "#!/bin/bash" :tangle tangle/merge.sh git checkout master @@ -20,10 +26,10 @@ git push --force origin master #+end_src ** Updating all tangled files -This script (re-)tangles all =.org= and =.org.gpg= files. Run this in -case the org files were updated outside of your local emacs (e.g. -after pulling from a remote). Make sure to run it from the dotfiles -directory. +This script (re-)tangles all =.org= and =.org.gpg= files in the +current directory. Run this in case the org files were updated outside +of your local emacs (e.g. after pulling from a remote). Make sure to +run it from the dotfiles directory. #+begin_src shell :shebang "#!/bin/bash" :tangle no emacs --batch --eval="\ @@ -32,9 +38,9 @@ emacs --batch --eval="\ (mapc 'org-babel-tangle-file (split-string \"$(ls *.org *.org.gpg)\"))))" #+end_src -The above won't quite work for me as I use ~org-crypt~ in some +The above won't quite work for me as I use [[https://orgmode.org/worg/org-tutorials/encrypting-files.html#org697961a][org-crypt]] in some configuration files and it also needs to be loaded & setup. For -details see [[file:emacs-init.org][emacs-init.org]]. +details see [[file:emacs-init.org::org-crypt-tangle-setup][emacs-init.org]]. #+begin_src shell :shebang "#!/bin/bash" :tangle tangle/tangle.sh emacs --batch --eval="\ @@ -65,7 +71,7 @@ the ~ln -siv~ calls: ~yes | tangle/link.sh~. Make sure to run it from the dotfiles directory. As the symlink shell source blocks are scattered in all configuration -files, all files are collected together using cat and then all blocks +files, all files are collected together using ~cat~ and then all blocks with the correct ~:tangle~ target are tangled. Unfortunately there is no function to directly only tangle blocks with a certain target, so this is not straightforward. @@ -86,8 +92,3 @@ rm $catFile $symlinkFile #+end_src - -* Window manager -I use [[https://github.com/ch11ng/exwm][exwm]] and [[https://awesomewm.org/][awesome]] as my window managers. When doing a lot of -coding and similar stuff I tend to use exwm as I will spend most of my -time in emacs anyway. -- cgit v1.2.3 From a965137b4b6fe572f4f5daee467000dd8404200c Mon Sep 17 00:00:00 2001 From: fpi Date: Wed, 15 Jul 2020 21:53:02 +0200 Subject: Add a script to pull from origin with rebase --- README.org | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'README.org') diff --git a/README.org b/README.org index 34ca2b7..c199c9e 100644 --- a/README.org +++ b/README.org @@ -25,6 +25,14 @@ git branch -a | grep -v -e +$ -e master | sed "s/[ *] //" | xargs git merge git push --force origin master #+end_src +To integrate changes from =origin= perform a rebase instead of merge +to loose the old merge commit but keep any local changes. + +#+begin_src shell :shebang "#!/bin/bash" :tangle tangle/pull.sh +git fetch +git rebase origin/master master +#+end_src + ** Updating all tangled files This script (re-)tangles all =.org= and =.org.gpg= files in the current directory. Run this in case the org files were updated outside -- cgit v1.2.3 From 8871fcd011884ed8e30cb572eb0a4d42acedf776 Mon Sep 17 00:00:00 2001 From: fpi Date: Wed, 15 Jul 2020 22:05:44 +0200 Subject: Add dots script --- README.org | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'README.org') diff --git a/README.org b/README.org index c199c9e..893befd 100644 --- a/README.org +++ b/README.org @@ -100,3 +100,18 @@ rm $catFile $symlinkFile #+end_src + +** =dots= script +I place this script in my =PATH= to execute commands in the dotfiles +directory from anywhere. + +#+begin_src shell :shebang "#!/bin/bash" :tangle tangle/dots.sh +cd ~/git/projects/dotfiles +$@ +#+end_src + +Create a symlink for this script. + +#+BEGIN_SRC sh :tangle tangle/symlink.sh :results silent :shebang "#!/bin/bash" +ln -siv $(pwd)/tangle/dots.sh ~/.local/bin/dots +#+END_SRC -- cgit v1.2.3 From 622e94a68126d7670a2dd40317e23730fccc153b Mon Sep 17 00:00:00 2001 From: fpi Date: Wed, 15 Jul 2020 22:41:26 +0200 Subject: Add make install target for fresh installations --- README.org | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'README.org') diff --git a/README.org b/README.org index 893befd..0afa693 100644 --- a/README.org +++ b/README.org @@ -9,7 +9,16 @@ The symlinks can be created by manually running the appropriate [[https://orgmod source block in each configuration file or by running the scripts below. -** Git Setup +** Initial setup +After cloning this repository run + +#+begin_example shell +make install +#+end_example + +to setup the tangled config files and create the necessary symlinks. + +** Git setup This repository somewhat abuses git branches. Every program's configuration lives in its own separate branch. All branches are then merged into =master= using an [[https://git-scm.com/docs/merge-strategies#Documentation/merge-strategies.txt-octopus][octopus merge]]. To keep the git history -- cgit v1.2.3 From 71194e54cd50a20d6d1dbe7e883e5a07ec6150e2 Mon Sep 17 00:00:00 2001 From: fpi Date: Mon, 27 Jul 2020 10:11:25 +0200 Subject: Add experimental way to reduce amount of tangling Works by saving the git commit hash upon tangling. Currently this does not record if tangling fails for some reason. --- README.org | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) (limited to 'README.org') diff --git a/README.org b/README.org index 0afa693..77f7917 100644 --- a/README.org +++ b/README.org @@ -1,3 +1,4 @@ +#+PROPERTY: header-args:shell :noweb yes * My dotfiles The config files are organized in [[https://www.gnu.org/software/emacs/][emacs]] [[https://orgmode.org/][org mode]] files. They are tangled and symlinked to the appropriate directories. @@ -60,6 +61,12 @@ configuration files and it also needs to be loaded & setup. For details see [[file:emacs-init.org::org-crypt-tangle-setup][emacs-init.org]]. #+begin_src shell :shebang "#!/bin/bash" :tangle tangle/tangle.sh +files=$(ls *.org *.org.gpg) + +<> + +echo "Tangling files:$tanglefiles ..." + emacs --batch --eval="\ (progn (require 'org) (require 'org-crypt) @@ -74,7 +81,58 @@ emacs --batch --eval="\ (org-encrypt-entries) (save-without-hook))) (let ((org-confirm-babel-evaluate nil)) - (mapc 'org-babel-tangle-file (split-string \"$(ls *.org *.org.gpg)\"))))" + (mapc 'org-babel-tangle-file (split-string \"$tanglefiles\"))))" +#+end_src + +*** Saving commit hashes to reduce tangling +To reduce the amount of unnecessary tangling, save the commit hash +upon tangling and check it before tangling again. + +Get the commit hash of a file using ~git log~. + +#+NAME: gethash +#+begin_src shell +function gethash { + git log -n 1 --pretty=format:%H -- $1 +} +#+end_src + +We can save all commit hashes by looping over all files. + +#+NAME: savehashes +#+begin_src shell +HASHDIR="hash" +<> +for file in $files +do + gethash $file > $HASHDIR/$file +done +#+end_src + +But we really want to check the saved hash against the current hash +first. If they do not match keep the file for tangling. + +#+NAME: checkhashes +#+begin_src shell +HASHDIR="hash" +tanglefiles="" +<> + +exec 3>&2 +exec 2> /dev/null # disable stderr + +for file in $files +do + if [ $(cat $HASHDIR/$file) == $(gethash $file) ] + then + : # noop + else # if strings not equal or ~cat~ fails + tanglefiles="$tanglefiles $file" + gethash $file > $HASHDIR/$file # save hash + fi +done + +exec 2>&3 #reset stderr #+end_src ** Creating symlinks -- cgit v1.2.3 From be0d464d273d8b8544cbfffabb42eb76f1884131 Mon Sep 17 00:00:00 2001 From: fpi Date: Mon, 27 Jul 2020 11:12:46 +0200 Subject: Add table of contents to readme --- README.org | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'README.org') diff --git a/README.org b/README.org index 77f7917..77ba004 100644 --- a/README.org +++ b/README.org @@ -1,4 +1,14 @@ #+PROPERTY: header-args:shell :noweb yes +* Contents :QUOTE:TOC_2_gh: +#+BEGIN_QUOTE +- [[#my-dotfiles][My dotfiles]] + - [[#initial-setup][Initial setup]] + - [[#git-setup][Git setup]] + - [[#updating-all-tangled-files][Updating all tangled files]] + - [[#creating-symlinks][Creating symlinks]] + - [[#dots-script][=dots= script]] +#+END_QUOTE + * My dotfiles The config files are organized in [[https://www.gnu.org/software/emacs/][emacs]] [[https://orgmode.org/][org mode]] files. They are tangled and symlinked to the appropriate directories. -- cgit v1.2.3 From aaefc71b6e7a58fcd13e0db1e1f01cf6b2a7f55a Mon Sep 17 00:00:00 2001 From: fpi Date: Sun, 23 Aug 2020 13:04:27 +0200 Subject: Create directory to save hashes if it does not exist --- README.org | 1 + 1 file changed, 1 insertion(+) (limited to 'README.org') diff --git a/README.org b/README.org index 77ba004..645e312 100644 --- a/README.org +++ b/README.org @@ -125,6 +125,7 @@ first. If they do not match keep the file for tangling. #+NAME: checkhashes #+begin_src shell HASHDIR="hash" +mkdir -p $HASHDIR tanglefiles="" <> -- cgit v1.2.3 From 5081f1a23ad4f98d953077dba7c3741d3a32fbf7 Mon Sep 17 00:00:00 2001 From: fpi Date: Sat, 14 May 2022 23:56:13 +0200 Subject: Make tangled files rx-only --- README.org | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'README.org') diff --git a/README.org b/README.org index 645e312..f336ad0 100644 --- a/README.org +++ b/README.org @@ -1,4 +1,4 @@ -#+PROPERTY: header-args:shell :noweb yes +#+PROPERTY: header-args:shell :noweb yes :tangle-mode (identity #o555) * Contents :QUOTE:TOC_2_gh: #+BEGIN_QUOTE - [[#my-dotfiles][My dotfiles]] -- cgit v1.2.3