commit cba4dae090e1696fd2dce28f1d37d546c5591b09
parent 2cda10b648ffa34a1d836c21f12217d9333507ef
Author: oscarbenedito <oscar@obenedito.org>
Date:   Sat, 16 Nov 2019 21:56:24 +0100

Changed files to use literate programming

Diffstat:
M.chezmoiignore | 1+
M.gitignore | 4++++
Ddot_bash_aliases.tmpl | 28----------------------------
Adot_bash_aliases.tmpl.md | 50++++++++++++++++++++++++++++++++++++++++++++++++++
Ddot_gitconfig.tmpl | 8--------
Adot_gitconfig.tmpl.md | 24++++++++++++++++++++++++
Ddot_scripts/executable_deploy-website.sh.tmpl | 14--------------
Adot_scripts/executable_deploy-website.sh.tmpl.md | 39+++++++++++++++++++++++++++++++++++++++
Ddot_scripts/executable_tmux-website.sh | 17-----------------
Adot_scripts/executable_tmux-website.sh.md | 34++++++++++++++++++++++++++++++++++
Mdot_vimrc.md | 22+++++++++++-----------
11 files changed, 163 insertions(+), 78 deletions(-)

diff --git a/.chezmoiignore b/.chezmoiignore @@ -1,5 +1,6 @@ markion.py *.md +.scripts/*.md {{ if not .website -}} .scripts {{- end }} diff --git a/.gitignore b/.gitignore @@ -1 +1,5 @@ dot_vimrc +dot_bash_aliases.tmpl +dot_gitconfig.tmpl +dot_scripts/executable_tmux-website.sh +dot_scripts/executable_deploy-website.sh.tmpl diff --git a/dot_bash_aliases.tmpl b/dot_bash_aliases.tmpl @@ -1,28 +0,0 @@ -alias upgrade="sudo {{ if eq .chezmoi.osRelease.id "debian" }}apt-get update && sudo apt-get upgrade{{ else }}pacman -Syyu{{ end }}" - -{{- if .backup }} -alias backup="rsync -gloptruzvP --delete --exclude={ - {{- range $i, $dir := .backup.backup_exclude }} - {{- if $i -}} - , - {{- end -}} - "{{ $dir }}" - {{- end -}} -} {{ .chezmoi.homedir }}/ /media/oscar/OSCAR/.{{ .backup.backup_dir }}/" -alias backup_vc_10="rsync -gloptruzvP --delete --exclude={ - {{- range $i, $dir := .backup.backup_exclude }} - {{- if $i -}} - , - {{- end -}} - "{{ $dir }}" - {{- end -}} - {{ range $dir := .backup.small_backup_exclude -}} - ,"{{ $dir }}" - {{- end -}} -} {{ .chezmoi.homedir }}/ /media/veracrypt10/{{ .backup.backup_dir }}/" -{{- end }} - -{{- if .website }} -alias website="~/.scripts/tmux-website.sh" -alias deploy_website="~/.scripts/deploy-website.sh" -{{- end }} diff --git a/dot_bash_aliases.tmpl.md b/dot_bash_aliases.tmpl.md @@ -0,0 +1,50 @@ +# File `.bash_aliases` + +Alias to update the system, diferent for Debian or Arch. +``` file dot_bash_aliases.tmpl +alias upgrade=" +{{- if eq .chezmoi.osRelease.id "debian" -}} + sudo apt-get update && sudo apt-get upgrade +{{- else -}} + sudo pacman -Syyu +{{- end }}" +``` + +## Backups +If backup is enabled in the `chezmoi` data, create backup alias, excluding the files specified in the `chezmoi` data. First is the complete backup alias: +``` file dot_bash_aliases.tmpl +{{- if .backup }} +alias backup="rsync -gloptruzvP --delete --exclude={ + {{- range $i, $dir := .backup.backup_exclude }} + {{- if $i -}} + , + {{- end -}} + "{{ $dir }}" + {{- end -}} +} {{ .chezmoi.homedir }}/ /media/oscar/OSCAR/.{{ .backup.backup_dir }}/" +``` + +And secondly the smaller backup, with extra excluded directories: +``` file dot_bash_aliases.tmpl +alias backup_vc_10="rsync -gloptruzvP --delete --exclude={ + {{- range $i, $dir := .backup.backup_exclude }} + {{- if $i -}} + , + {{- end -}} + "{{ $dir }}" + {{- end -}} + {{ range $dir := .backup.small_backup_exclude -}} + ,"{{ $dir }}" + {{- end -}} +} {{ .chezmoi.homedir }}/ /media/veracrypt10/{{ .backup.backup_dir }}/" +{{- end }} +``` + +## Website +If website is enabled in the `chezmoi` configuration, we create aliases to the scripts to open the website working environment the to deploy the website. +``` file dot_bash_aliases.tmpl +{{- if .website }} +alias website="~/.scripts/tmux-website.sh" +alias deploy_website="~/.scripts/deploy-website.sh" +{{- end }} +``` diff --git a/dot_gitconfig.tmpl b/dot_gitconfig.tmpl @@ -1,8 +0,0 @@ -[user] - email = oscar@obenedito.org - name = oscarbenedito -{{- if .pgpkey }} - signingkey = 827E5A8E3AE8A499 -[commit] - gpgsign = true -{{- end }} diff --git a/dot_gitconfig.tmpl.md b/dot_gitconfig.tmpl.md @@ -0,0 +1,24 @@ +# File `.gitconfig` + +Adding git user account. +```toml file dot_gitconfig.tmpl +[user] + email = oscar@obenedito.org + name = oscarbenedito + [[ include pgpsigningkey]] +``` +## PGP key +If specified in the `chezmoi` data, configure the signing key. Note that the following code is the block included with `pgpsigningkey`. +```toml block pgpsigningkey +{{- if .pgpkey }} +signingkey = 827E5A8E3AE8A499 +{{- end }} +``` + +If a PGP is used, we'll add the following line to sign commits by default. +```toml file dot_gitconfig.tmpl +{{- if .pgpkey }} +[commit] + gpgsign = true +{{- end }} +``` diff --git a/dot_scripts/executable_deploy-website.sh.tmpl b/dot_scripts/executable_deploy-website.sh.tmpl @@ -1,14 +0,0 @@ -#!/bin/bash - -HUGO_PATH="{{ .chezmoi.homedir }}/Git/obenedito.org" -TEMP_DIR="{{ .chezmoi.homedir }}/.tmp-webdav" -MOUNT_PATH="/media/obenedito" -WEBDAV_FOLDER="html-obenedito.org" - -rm -rf $HUGO_PATH/public -hugo -s $HUGO_PATH --minify -mount $MOUNT_PATH -mkdir $TEMP_DIR -rsync -ruvc --progress --delete --temp-dir=$TEMP_DIR $HUGO_PATH/public/ $MOUNT_PATH/$WEBDAV_FOLDER -rmdir $TEMP_DIR -umount $MOUNT_PATH diff --git a/dot_scripts/executable_deploy-website.sh.tmpl.md b/dot_scripts/executable_deploy-website.sh.tmpl.md @@ -0,0 +1,39 @@ +# File `deploy-website.sh` +This file automatically deploys my website, given the appropriate configuration on the machine. + +## File description +Shebang line and setting up the variables. +```bash file executable_deploy-website.sh.tmpl +#!/bin/bash +HUGO_PATH="{{ .chezmoi.homedir }}/Git/obenedito.org" +TEMP_DIR="{{ .chezmoi.homedir }}/.tmp-webdav" +MOUNT_PATH="/media/obenedito" +WEBDAV_FOLDER="html-obenedito.org" +``` + +We delete the previous build site on the folder (as far as I have noticed, Hugo doesn't delete the files by default, so deleted files would still be in the new build if this line wasn't here). +```bash file executable_deploy-website.sh.tmpl +rm -rf $HUGO_PATH/public +``` + +We build the website +```bash file executable_deploy-website.sh.tmpl +hugo -s $HUGO_PATH --minify +``` + +We mount the filesystem with WebDAV (considering it is well configured) and we create the temporary directory for the `rsync` call. +```bash file executable_deploy-website.sh.tmpl +mount $MOUNT_PATH +mkdir $TEMP_DIR +``` + +We synchronize the files with `rsync`. +```bash file executable_deploy-website.sh.tmpl +rsync -ruvc --progress --delete --temp-dir=$TEMP_DIR $HUGO_PATH/public/ $MOUNT_PATH/$WEBDAV_FOLDER +``` + +Finally, we remove the temporary directory and unmount the filesystem. +```bash file executable_deploy-website.sh.tmpl +rmdir $TEMP_DIR +umount $MOUNT_PATH +``` diff --git a/dot_scripts/executable_tmux-website.sh b/dot_scripts/executable_tmux-website.sh @@ -1,17 +0,0 @@ -#!/bin/bash -SESSION=$USER - -setxkbmap es -tmux -2 new-session -d -s $SESSION - -# Setup window -tmux new-window -t $SESSION:1 -n 'hugo' -tmux send-keys "cd ~/Git/obenedito.org" C-m -tmux send-keys "hugo server" C-m -tmux select-window -t $SESSION:0 -tmux send-keys "cd ~/Git/obenedito.org" C-m -tmux send-keys "atom . &" C-m -tmux send-keys "firefox http://localhost:1313/ &" C-m - -# Attach to session -tmux -2 attach-session -t $SESSION diff --git a/dot_scripts/executable_tmux-website.sh.md b/dot_scripts/executable_tmux-website.sh.md @@ -0,0 +1,34 @@ +# File `tmux-website.sh` +This file is a script to automatically open the needed programs to work on my website. + +## File description +Setting up varibles and keyboard setup. +```bash file executable_tmux-website.sh +#!/bin/bash +SESSION=$USER +setxkbmap es +``` + +Create a new tmux session. +```bash file executable_tmux-website.sh +tmux -2 new-session -d -s $SESSION +``` + +Create a new window called `hugo` and run `hugo server` in it. +```bash file executable_tmux-website.sh +tmux new-window -t $SESSION:1 -n 'hugo' +tmux send-keys "cd ~/Git/obenedito.org" C-m +tmux send-keys "hugo server" C-m +``` +In the window number 0, open the folder with Atom and open the local server on Firefox. +```bash file executable_tmux-website.sh +tmux select-window -t $SESSION:0 +tmux send-keys "cd ~/Git/obenedito.org" C-m +tmux send-keys "atom . &" C-m +tmux send-keys "firefox http://localhost:1313/ &" C-m +``` + +Finally, we attach to the session. +```bash file executable_tmux-website.sh +tmux -2 attach-session -t $SESSION +``` diff --git a/dot_vimrc.md b/dot_vimrc.md @@ -2,22 +2,22 @@ ## Latex-Suite First of all we include the code required by `vim-latexsuite`. The following code is required and it makes vim invoke Latex-Suite when you open a tex file. -```python file dot_vimrc +```vim file dot_vimrc filetype plugin on ``` The following code is important as grep will sometimes skip displaying the file name if you search in a singe file. This will confuse Latex-Suite. Set your grep program to always generate a file-name. -```python file dot_vimrc +```vim file dot_vimrc set grepprg=grep\ -nH\ $* ``` The following code is optional and it enables automatic indentation as you type. -```python file dot_vimrc +```vim file dot_vimrc filetype indent on ``` The following code is optional. Starting with Vim 7, the filetype of empty `.tex` files defaults to 'plaintex' instead of 'tex', which results in vim-latex not being loaded. The following changes the default filetype back to 'tex': -```python file dot_vimrc +```vim file dot_vimrc let g:tex_flavor='latex' let g:Tex_Folding=0 let g:Tex_AutoFolding=0 @@ -25,41 +25,41 @@ let g:Tex_AutoFolding=0 ## Defaults Configures indentation. -```python file dot_vimrc +```vim file dot_vimrc set expandtab set shiftwidth=2 set tabstop=2 ``` Configures syntax coloring. -```python file dot_vimrc +```vim file dot_vimrc syntax on ``` Show line number and other lines' relative number. -```python file dot_vimrc +```vim file dot_vimrc set number set relativenumber ``` Setting the folding method to marker (you should use `{{{` and `}}}` to delimit areas that should fold). -```python file dot_vimrc +```vim file dot_vimrc set foldmethod=marker ``` Set modeline to be able to change defaults in a per file basis. -```python file dot_vimrc +```vim file dot_vimrc set modeline ``` ## Other useful commands Shortcut to execute the make command. -```python file dot_vimrc +```vim file dot_vimrc :command Make :w | :!make ``` Sets the filetype for Latex documents. -```python file dot_vimrc +```vim file dot_vimrc autocmd BufRead,BufNewFile *.tex set filetype=tex autocmd BufRead,BufNewFile *.cls set filetype=tex autocmd BufRead,BufNewFile *.sty set filetype=tex