added editorconfig, pre commit hooks

This commit is contained in:
Tobias Schmidl 2023-10-05 10:14:04 +02:00
parent 0561f9eb04
commit 266ea2e006
10 changed files with 123 additions and 33 deletions

19
.editorconfig Normal file
View file

@ -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

28
.pre-commit-config.yaml Normal file
View file

@ -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
...

View file

@ -1,4 +1,9 @@
#! /bin/zsh #! /bin/zsh
# SPDX-FileCopyrightText: 2023 Tobias Schmidl
#
# SPDX-License-Identifier: GPL-3.0-or-later
# shellcheck shell=bash # shellcheck shell=bash
alias cdiff="colordiff" alias cdiff="colordiff"

View file

@ -1,4 +1,9 @@
#! /bin/zsh #! /bin/zsh
# SPDX-FileCopyrightText: 2023 Tobias Schmidl
#
# SPDX-License-Identifier: GPL-3.0-or-later
# shellcheck shell=bash # shellcheck shell=bash
alias bathelp='bat --plain --language=help' alias bathelp='bat --plain --language=help'

View file

@ -1,4 +1,9 @@
#! /bin/zsh #! /bin/zsh
# SPDX-FileCopyrightText: 2023 Tobias Schmidl
#
# SPDX-License-Identifier: GPL-3.0-or-later
# shellcheck shell=bash # shellcheck shell=bash
function escape() { perl -MURI::Escape -e 'print uri_escape($ARGV[0]);' "$@"; } function escape() { perl -MURI::Escape -e 'print uri_escape($ARGV[0]);' "$@"; }

View file

@ -1,4 +1,9 @@
#! /bin/zsh #! /bin/zsh
# SPDX-FileCopyrightText: 2023 Tobias Schmidl
#
# SPDX-License-Identifier: GPL-3.0-or-later
# shellcheck shell=bash # shellcheck shell=bash
# this is ripped off serverfault https://serverfault.com/a/90401 # this is ripped off serverfault https://serverfault.com/a/90401

View file

@ -1,5 +1,10 @@
#! /bin/zsh #! /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 exa='exa -FHhg@ --git --binary --time-style long-iso'
alias exal='exa -l' alias exal='exa -l'

32
fzf.zsh
View file

@ -1,29 +1,35 @@
#! /bin/zsh #! /bin/zsh
# SPDX-FileCopyrightText: 2023 Tobias Schmidl
#
# SPDX-License-Identifier: GPL-3.0-or-later
# shellcheck shell=bash # shellcheck shell=bash
# shellcheck disable=1091
export FZF_COMPLETION_OPTS='--border --info=inline' export FZF_COMPLETION_OPTS='--border --info=inline'
if [ -n "$TERMUX_VERSION" ] && [ -d "$PREFIX" ]; if [ -n "$TERMUX_VERSION" ] && [ -d "$PREFIX" ];
then then
source "$PREFIX/share/fzf/completion.zsh" source "$PREFIX/share/fzf/completion.zsh"
source "$PREFIX/share/fzf/key-bindings.zsh" source "$PREFIX/share/fzf/key-bindings.zsh"
else else
source /usr/share/doc/fzf/examples/completion.zsh source /usr/share/doc/fzf/examples/completion.zsh
source /usr/share/doc/fzf/examples/key-bindings.zsh source /usr/share/doc/fzf/examples/key-bindings.zsh
fi fi
# (EXPERIMENTAL) Advanced customization of fzf options via _fzf_comprun function # (EXPERIMENTAL) Advanced customization of fzf options via _fzf_comprun function
# - The first argument to the function is the name of the command. # - 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. # - You should make sure to pass the rest of the arguments to fzf.
_fzf_comprun() { _fzf_comprun() {
local command=$1 local command=$1
shift shift
case "$command" in case "$command" in
vim|nvim|nano) fzf "$@" --preview 'batcat --color=always {}' ;; vim|nvim|nano) fzf "$@" --preview 'batcat --color=always {}' ;;
cd) fzf "$@" --preview 'tree -C {} | head -200' ;; cd) fzf "$@" --preview 'tree -C {} | head -200' ;;
export|unset) fzf "$@" --preview "eval 'echo \$'{}" ;; export|unset) fzf "$@" --preview "eval 'echo \$'{}" ;;
ssh) fzf "$@" --preview 'dig {}' ;; ssh) fzf "$@" --preview 'dig {}' ;;
*) fzf "$@" ;; *) fzf "$@" ;;
esac esac
} }

View file

@ -1,17 +1,22 @@
#! /bin/zsh #! /bin/zsh
# shellcheck shell=bash
# SPDX-FileCopyrightText: 2023 Tobias Schmidl
#
# SPDX-License-Identifier: GPL-3.0-or-later
# shellcheck disable=all
user_commands=( user_commands=(
list-units is-active status show help list-unit-files list-units is-active status show help list-unit-files
is-enabled list-jobs show-environment cat list-timers is-enabled list-jobs show-environment cat list-timers
is-system-running default rescue halt poweroff reboot is-system-running default rescue halt poweroff reboot
emergency kexec exit suspend hibernate hybrid-sleep) emergency kexec exit suspend hibernate hybrid-sleep)
sudo_commands=( sudo_commands=(
start stop reload restart try-restart isolate kill start stop reload restart try-restart isolate kill
reset-failed enable disable reenable preset mask unmask reset-failed enable disable reenable preset mask unmask
link load cancel set-environment unset-environment link load cancel set-environment unset-environment
edit) edit)
for c in $user_commands; do; alias sc-$c="systemctl $c"; done 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 for c in $sudo_commands; do; alias sc-$c="sudo systemctl $c"; done

View file

@ -1,21 +1,28 @@
#! /bin/zsh #! /bin/zsh
# SPDX-FileCopyrightText: 2023 Tobias Schmidl
#
# SPDX-License-Identifier: GPL-3.0-or-later
# shellcheck shell=bash # shellcheck shell=bash
# shellcheck disable=SC1091
[ -z "$EDITOR" ] && export EDITOR=sensible-editor [ -z "$EDITOR" ] && export EDITOR=sensible-editor
export LESS="-F -R" export LESS="-F -R"
[ -r "$HOME/.config/user-dirs.dirs" -a \ [ -r "$HOME/.config/user-dirs.dirs" ] &&\
-z "$XDG_DESKTOP_DIR" -a \ [ -z "$XDG_DESKTOP_DIR" ] && \
-z "$XDG_DOWNLOAD_DIR" -a \ [ -z "$XDG_DOWNLOAD_DIR" ] && \
-z "$XDG_TEMPLATES_DIR" -a \ [ -z "$XDG_TEMPLATES_DIR" ] && \
-z "$XDG_PUBLICSHARE_DIR" -a \ [ -z "$XDG_PUBLICSHARE_DIR" ] && \
-z "$XDG_DOCUMENTS_DIR" -a \ [ -z "$XDG_DOCUMENTS_DIR" ] && \
-z "$XDG_MUSIC_DIR" -a \ [ -z "$XDG_MUSIC_DIR" ] && \
-z "$XDG_PICTURES_DIR" -a \ [ -z "$XDG_PICTURES_DIR" ] && \
-z "$XDG_VIDEOS_DIR" ] && . "$HOME/.config/user-dirs.dirs" [ -z "$XDG_VIDEOS_DIR" ] && \
. "$HOME/.config/user-dirs.dirs"
export MAILCHECK=1 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 which todo > /dev/null && todo ls