From 266ea2e0067e48d11e9208dc2ec7df88e00c9e9a Mon Sep 17 00:00:00 2001 From: Tobias Schmidl Date: Thu, 5 Oct 2023 10:14:04 +0200 Subject: [PATCH] added editorconfig, pre commit hooks --- .editorconfig | 19 +++++++++++++++++++ .pre-commit-config.yaml | 28 ++++++++++++++++++++++++++++ aliases.zsh | 5 +++++ batcat.zsh | 5 +++++ browser.zsh | 5 +++++ debfunctions.zsh | 5 +++++ exa.zsh | 7 ++++++- fzf.zsh | 32 +++++++++++++++++++------------- systemd.zsh | 23 ++++++++++++++--------- zinit.zsh | 27 +++++++++++++++++---------- 10 files changed, 123 insertions(+), 33 deletions(-) create mode 100644 .editorconfig create mode 100644 .pre-commit-config.yaml diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..e63d848 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,19 @@ +# SPDX-FileCopyrightText: 2023 Tobias Schmidl +# +# SPDX-License-Identifier: GPL-3.0-or-later + +# EditorConfig is awesome: https://EditorConfig.org + +# top-most EditorConfig file +root = true + +[*] +indent_style = space +indent_size = 4 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.{yaml,yml}] +indent_size = 2 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..32644c7 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,28 @@ +# SPDX-FileCopyrightText: 2023 Tobias Schmidl +# +# SPDX-License-Identifier: GPL-3.0-or-later + +--- +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: check-yaml + - id: end-of-file-fixer + - id: trailing-whitespace + - id: check-merge-conflict + - id: check-byte-order-marker +- repo: https://github.com/fsfe/reuse-tool + rev: v2.1.0 + hooks: + - id: reuse +- repo: https://github.com/editorconfig-checker/editorconfig-checker.python + rev: '2.7.2' + hooks: + - id: editorconfig-checker + alias: ec +- repo: https://github.com/shellcheck-py/shellcheck-py + rev: v0.9.0.6 + hooks: + - id: shellcheck +... diff --git a/aliases.zsh b/aliases.zsh index da3bf1a..05abd0b 100644 --- a/aliases.zsh +++ b/aliases.zsh @@ -1,4 +1,9 @@ #! /bin/zsh + +# SPDX-FileCopyrightText: 2023 Tobias Schmidl +# +# SPDX-License-Identifier: GPL-3.0-or-later + # shellcheck shell=bash alias cdiff="colordiff" diff --git a/batcat.zsh b/batcat.zsh index d44984d..d43a946 100644 --- a/batcat.zsh +++ b/batcat.zsh @@ -1,4 +1,9 @@ #! /bin/zsh + +# SPDX-FileCopyrightText: 2023 Tobias Schmidl +# +# SPDX-License-Identifier: GPL-3.0-or-later + # shellcheck shell=bash alias bathelp='bat --plain --language=help' diff --git a/browser.zsh b/browser.zsh index 0e575da..7e05473 100644 --- a/browser.zsh +++ b/browser.zsh @@ -1,4 +1,9 @@ #! /bin/zsh + +# SPDX-FileCopyrightText: 2023 Tobias Schmidl +# +# SPDX-License-Identifier: GPL-3.0-or-later + # shellcheck shell=bash function escape() { perl -MURI::Escape -e 'print uri_escape($ARGV[0]);' "$@"; } diff --git a/debfunctions.zsh b/debfunctions.zsh index dfb7522..d97891e 100644 --- a/debfunctions.zsh +++ b/debfunctions.zsh @@ -1,4 +1,9 @@ #! /bin/zsh + +# SPDX-FileCopyrightText: 2023 Tobias Schmidl +# +# SPDX-License-Identifier: GPL-3.0-or-later + # shellcheck shell=bash # this is ripped off serverfault https://serverfault.com/a/90401 diff --git a/exa.zsh b/exa.zsh index a6c1057..7e006bc 100644 --- a/exa.zsh +++ b/exa.zsh @@ -1,5 +1,10 @@ #! /bin/zsh -# shellcheck shell=bash + +# SPDX-FileCopyrightText: 2023 Tobias Schmidl +# +# SPDX-License-Identifier: GPL-3.0-or-later + +# shellcheck disable=all alias exa='exa -FHhg@ --git --binary --time-style long-iso' alias exal='exa -l' diff --git a/fzf.zsh b/fzf.zsh index b86b474..596037e 100644 --- a/fzf.zsh +++ b/fzf.zsh @@ -1,29 +1,35 @@ #! /bin/zsh + +# SPDX-FileCopyrightText: 2023 Tobias Schmidl +# +# SPDX-License-Identifier: GPL-3.0-or-later + # shellcheck shell=bash +# shellcheck disable=1091 export FZF_COMPLETION_OPTS='--border --info=inline' if [ -n "$TERMUX_VERSION" ] && [ -d "$PREFIX" ]; then - source "$PREFIX/share/fzf/completion.zsh" - source "$PREFIX/share/fzf/key-bindings.zsh" + source "$PREFIX/share/fzf/completion.zsh" + source "$PREFIX/share/fzf/key-bindings.zsh" else - source /usr/share/doc/fzf/examples/completion.zsh - source /usr/share/doc/fzf/examples/key-bindings.zsh + source /usr/share/doc/fzf/examples/completion.zsh + source /usr/share/doc/fzf/examples/key-bindings.zsh fi # (EXPERIMENTAL) Advanced customization of fzf options via _fzf_comprun function # - The first argument to the function is the name of the command. # - You should make sure to pass the rest of the arguments to fzf. _fzf_comprun() { - local command=$1 - shift + local command=$1 + shift - case "$command" in - vim|nvim|nano) fzf "$@" --preview 'batcat --color=always {}' ;; - cd) fzf "$@" --preview 'tree -C {} | head -200' ;; - export|unset) fzf "$@" --preview "eval 'echo \$'{}" ;; - ssh) fzf "$@" --preview 'dig {}' ;; - *) fzf "$@" ;; - esac + case "$command" in + vim|nvim|nano) fzf "$@" --preview 'batcat --color=always {}' ;; + cd) fzf "$@" --preview 'tree -C {} | head -200' ;; + export|unset) fzf "$@" --preview "eval 'echo \$'{}" ;; + ssh) fzf "$@" --preview 'dig {}' ;; + *) fzf "$@" ;; + esac } diff --git a/systemd.zsh b/systemd.zsh index 9941dcf..f8278d9 100644 --- a/systemd.zsh +++ b/systemd.zsh @@ -1,17 +1,22 @@ #! /bin/zsh -# shellcheck shell=bash + +# SPDX-FileCopyrightText: 2023 Tobias Schmidl +# +# SPDX-License-Identifier: GPL-3.0-or-later + +# shellcheck disable=all user_commands=( - list-units is-active status show help list-unit-files - is-enabled list-jobs show-environment cat list-timers - is-system-running default rescue halt poweroff reboot - emergency kexec exit suspend hibernate hybrid-sleep) + list-units is-active status show help list-unit-files + is-enabled list-jobs show-environment cat list-timers + is-system-running default rescue halt poweroff reboot + emergency kexec exit suspend hibernate hybrid-sleep) sudo_commands=( - start stop reload restart try-restart isolate kill - reset-failed enable disable reenable preset mask unmask - link load cancel set-environment unset-environment - edit) + start stop reload restart try-restart isolate kill + reset-failed enable disable reenable preset mask unmask + link load cancel set-environment unset-environment + edit) for c in $user_commands; do; alias sc-$c="systemctl $c"; done for c in $sudo_commands; do; alias sc-$c="sudo systemctl $c"; done diff --git a/zinit.zsh b/zinit.zsh index 0c84e60..fee173d 100644 --- a/zinit.zsh +++ b/zinit.zsh @@ -1,21 +1,28 @@ #! /bin/zsh + +# SPDX-FileCopyrightText: 2023 Tobias Schmidl +# +# SPDX-License-Identifier: GPL-3.0-or-later + # shellcheck shell=bash +# shellcheck disable=SC1091 [ -z "$EDITOR" ] && export EDITOR=sensible-editor export LESS="-F -R" -[ -r "$HOME/.config/user-dirs.dirs" -a \ - -z "$XDG_DESKTOP_DIR" -a \ - -z "$XDG_DOWNLOAD_DIR" -a \ - -z "$XDG_TEMPLATES_DIR" -a \ - -z "$XDG_PUBLICSHARE_DIR" -a \ - -z "$XDG_DOCUMENTS_DIR" -a \ - -z "$XDG_MUSIC_DIR" -a \ - -z "$XDG_PICTURES_DIR" -a \ - -z "$XDG_VIDEOS_DIR" ] && . "$HOME/.config/user-dirs.dirs" +[ -r "$HOME/.config/user-dirs.dirs" ] &&\ + [ -z "$XDG_DESKTOP_DIR" ] && \ + [ -z "$XDG_DOWNLOAD_DIR" ] && \ + [ -z "$XDG_TEMPLATES_DIR" ] && \ + [ -z "$XDG_PUBLICSHARE_DIR" ] && \ + [ -z "$XDG_DOCUMENTS_DIR" ] && \ + [ -z "$XDG_MUSIC_DIR" ] && \ + [ -z "$XDG_PICTURES_DIR" ] && \ + [ -z "$XDG_VIDEOS_DIR" ] && \ + . "$HOME/.config/user-dirs.dirs" export MAILCHECK=1 -which fortune >/dev/null && which cowsay > /dev/null && fortune -e debian house-harkonnen house-atreides pratchett | cowsay -f tux -W 76 -n +which fortune >/dev/null && which cowsay > /dev/null && fortune -u debian house-harkonnen house-atreides pratchett | cowsay -f tux -W 76 -n which todo > /dev/null && todo ls