From 8a255d17fe1e71132d09b4aa53f2c4c905dc3102 Mon Sep 17 00:00:00 2001 From: Michele Cereda Date: Sun, 24 Apr 2022 15:27:47 +0200 Subject: [PATCH] Added pre-commit hooks --- .pre-commit-config.yaml | 14 ++++++++++++++ examples/arch linux/install-on-crypted-boot.sh | 12 ++++++------ examples/move-to-zsh.sh | 2 +- examples/raspberry pi os/salt-and-other-stuff.bash | 10 +++++----- knowledge base/git.md | 2 +- knowledge base/grep.md | 4 ++-- knowledge base/jdupes.md | 2 +- knowledge base/mac os x.md | 2 +- knowledge base/mktemp.md | 2 +- knowledge base/opkg.md | 2 +- knowledge base/pdfgrep.md | 1 + ...hange-the-default-branch-from-master-to-main.sh | 2 +- 12 files changed, 35 insertions(+), 20 deletions(-) create mode 100644 .pre-commit-config.yaml create mode 100644 knowledge base/pdfgrep.md diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..9519599 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,14 @@ +--- +# See https://pre-commit.com for more information +# See https://pre-commit.com/hooks.html for more hooks + +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.2.0 + hooks: + - id: trailing-whitespace + args: + - --markdown-linebreak-ext=md # ignore markdown's line break + - id: end-of-file-fixer + - id: check-yaml + - id: check-added-large-files diff --git a/examples/arch linux/install-on-crypted-boot.sh b/examples/arch linux/install-on-crypted-boot.sh index 24ca835..bd11208 100644 --- a/examples/arch linux/install-on-crypted-boot.sh +++ b/examples/arch linux/install-on-crypted-boot.sh @@ -163,7 +163,7 @@ ping -c 3 github.com lsblk # create 2 partitions: -# partition 1: +# partition 1: # - EFI # - size 512 MiB # - hex code ef00 @@ -400,7 +400,7 @@ sudo modprobe btusb sudo systemctl start bluetooth.service sudo systemctl enable bluetooth.service -# auto enable Bluetooth +# auto enable Bluetooth # change AutoEnable to true in the [Policy] section: # #SET AutoEnable=True @@ -424,7 +424,7 @@ cd yay makepkg -si # install fonts -sudo pacman -S adobe-source-code-pro-fonts adobe-source-han-sans-cn-fonts adobe-source-han-sans-jp-fonts adobe-source-han-sans-kr-fonts adobe-source-han-sans-otc-fonts adobe-source-han-sans-tw-fonts adobe-source-sans-pro-fonts noto-fonts-emoji otf-ipafont ttf-dejavu ttf-hanazono ttf-inconsolata ttf-liberation ttf-roboto ttf-ubuntu-font-family +sudo pacman -S adobe-source-code-pro-fonts adobe-source-han-sans-cn-fonts adobe-source-han-sans-jp-fonts adobe-source-han-sans-kr-fonts adobe-source-han-sans-otc-fonts adobe-source-han-sans-tw-fonts adobe-source-sans-pro-fonts noto-fonts-emoji otf-ipafont ttf-dejavu ttf-hanazono ttf-inconsolata ttf-liberation ttf-roboto ttf-ubuntu-font-family yay -S ttf-google-fonts-git ttf-ms-fonts # install some more QOL utilities @@ -435,10 +435,10 @@ yay -S etcher-bin brave-bin spotify skypeforlinux-stable-bin timeshift # create a script with the following content: # # #!/bin/sh -# +# # APPLICATION_PATH="/usr/share/applications" # USER_APPLICATION_PATH="${HOME}/.local/share/applications" -# +# # for FILE in cat $1; do # if [ -e "${APPLICATION_PATH}/${FILE}" ]; then # echo "Creating file ${USER_APPLICATION_PATH}/${FILE}" @@ -447,7 +447,7 @@ yay -S etcher-bin brave-bin spotify skypeforlinux-stable-bin timeshift # echo "Deleting unnecessary file ${USER_APPLICATION_PATH}/${FILE}" # rm "${USER_APPLICATION_PATH}/${FILE}" # fi -# done +# done # vim ~/hide_desktop_icons.sh diff --git a/examples/move-to-zsh.sh b/examples/move-to-zsh.sh index 181b85e..c634421 100755 --- a/examples/move-to-zsh.sh +++ b/examples/move-to-zsh.sh @@ -9,4 +9,4 @@ cp --backup /usr/share/oh-my-zsh/zshrc ~/.zshrc sed -Ei 's/#*\s*(ZSH_THEME)=.*/\1="refined"/' ~/.zshrc sed -Ei 's/#*\s*(COMPLETION_WAITING_DOTS)=.*/\1="true"/' ~/.zshrc sed -Ei 's/#*\s*(HIST_STAMPS)=.*/\1="yyyy-mm-dd"/' ~/.zshrc -# set plugins=() to (git minikube terraform) +# set plugins=() to (git minikube terraform) diff --git a/examples/raspberry pi os/salt-and-other-stuff.bash b/examples/raspberry pi os/salt-and-other-stuff.bash index e563f49..4e67ef2 100755 --- a/examples/raspberry pi os/salt-and-other-stuff.bash +++ b/examples/raspberry pi os/salt-and-other-stuff.bash @@ -8,11 +8,11 @@ sudo gpasswd -a pi salt passwd sudo hostnamectl set-hostname pi4.lan sudo vim.tiny /etc/salt/minion.d/master.conf -sudo rm /etc/salt/minion_id +sudo rm /etc/salt/minion_id sudo shutdown -r now sudo salt-key --list all sudo timedatectl set-timezone Europe/Dublin -sudo timedatectl status +sudo timedatectl status sudo salt-key --list all sudo salt-key --accept pi4.lan sudo systemctl enable --now ssh.service @@ -25,12 +25,12 @@ mkdir -p docker/boinc-client docker/pi-hole docker/nextcloud cd docker/boinc-client vim.tiny docker-compose.yml docker-compose up -d -docker-compose logs --follow +docker-compose logs --follow cd ../pi-hole -vim.tiny docker-compose.yml +vim.tiny docker-compose.yml docker-compose up -d docker-compose logs -f sudo vim.tiny /etc/locale.gen -sudo locale-gen +sudo locale-gen sudo localectl set-locale LANG=en_IE.utf8 LANGUAGE=en_IE.utf8 mkdir -p repositories/private diff --git a/knowledge base/git.md b/knowledge base/git.md index 5edf6cc..d104b47 100644 --- a/knowledge base/git.md +++ b/knowledge base/git.md @@ -373,7 +373,7 @@ Just save the output from `git diff` to get a patch file: git diff > file.patch # Staged files only. -git diff --output file.patch --cached +git diff --output file.patch --cached ``` The output from `git diff` just shows changes to **text** files by default, no metadata or other information about commits or branches. diff --git a/knowledge base/grep.md b/knowledge base/grep.md index 81dbf52..edaa425 100644 --- a/knowledge base/grep.md +++ b/knowledge base/grep.md @@ -37,9 +37,9 @@ find . -type f -print0 | xargs -0 -n 1 -P $(nproc) grep 'pattern' For simple searches, you might want to use [pdfgrep]. Should you need more advanced grep capabilities not incorporated by pdfgrep, you might want to convert the file to text and search there. -You can to this using [`pdftotext`](pdfgrep.md) as shown in this example ([source][stackoverflow answer about how to search contents of multiple pdf files]): +You can to this using [pdftotext](pdfgrep.md) as shown in this example ([source][stackoverflow answer about how to search contents of multiple pdf files]): -```sh +```shell find /path -name '*.pdf' -exec sh -c 'pdftotext "{}" - | grep --with-filename --label="{}" --color "your pattern"' ';' ``` diff --git a/knowledge base/jdupes.md b/knowledge base/jdupes.md index b196057..1ea1e82 100644 --- a/knowledge base/jdupes.md +++ b/knowledge base/jdupes.md @@ -1,4 +1,4 @@ -# `jdupes` +# Jdupes ## TL;DR diff --git a/knowledge base/mac os x.md b/knowledge base/mac os x.md index cd664aa..1352da1 100644 --- a/knowledge base/mac os x.md +++ b/knowledge base/mac os x.md @@ -1,4 +1,4 @@ -# Mac OS X +# Mac OS X - [TL;DR](#tldr) - [Xcode CLI tools](#xcode-cli-tools) diff --git a/knowledge base/mktemp.md b/knowledge base/mktemp.md index b6dc917..f5cff5c 100644 --- a/knowledge base/mktemp.md +++ b/knowledge base/mktemp.md @@ -8,7 +8,7 @@ Creates a unique temporary file or directory and returns the absolute path to it # create an empty temporary file mktemp -# create an empty temporary directory +# create an empty temporary directory mktemp -d # create an empty temporary file or directory with a random templated name diff --git a/knowledge base/opkg.md b/knowledge base/opkg.md index 86afd63..c462273 100644 --- a/knowledge base/opkg.md +++ b/knowledge base/opkg.md @@ -31,7 +31,7 @@ opkg info python3-dns # list packages providing a file opkg search /usr/bin/vim -# list user modified configuration files +# list user modified configuration files opkg list-changed-conffiles # list dependencies of a package diff --git a/knowledge base/pdfgrep.md b/knowledge base/pdfgrep.md new file mode 100644 index 0000000..77d6c78 --- /dev/null +++ b/knowledge base/pdfgrep.md @@ -0,0 +1 @@ +# PDFGrep diff --git a/scripts/git/change-the-default-branch-from-master-to-main.sh b/scripts/git/change-the-default-branch-from-master-to-main.sh index e0f183c..b85df4d 100755 --- a/scripts/git/change-the-default-branch-from-master-to-main.sh +++ b/scripts/git/change-the-default-branch-from-master-to-main.sh @@ -6,7 +6,7 @@ # create main branch locally, taking the history from master git branch --move master main -# push the new local main branch to the remote repo (GitHub) +# push the new local main branch to the remote repo (GitHub) git push --set-upstream origin main # switch the current HEAD to the main branch