From 291f3ebeb93995052fe89aa5fda500df62d594c3 Mon Sep 17 00:00:00 2001 From: Harald Pfeiffer Date: Sun, 14 Jul 2024 13:24:05 +0200 Subject: git-prompt, flake8, pass-git-helper, gpg trust model, SSH control master, python indent 1. Before we had no real inclusion of git-prompt in this repo. Now, we have included git's own git-prompt. Alternatives were tested and failed to meet KISS, YAGNI, or one-task-one-solution principles. 2. Include $HOME/go/bin in PATH 3. Set flake8's max-cognitive-complexity to 16 4. Set up pass-git-helper as git's credential helper, set pack.windowMemory to 1024m 5. Set trust-model of GPG to tofu+gpg 6. Do not use tabs in python anymore, bow to global byte-consuming standard 7. Do not use SSH ControlMaster as default anymore --- Squashed commit of the following: commit 035b47b860b96a3c4bf24ed53f9753f6dac77097 Author: Harald Pfeiffer Date: Sun Jul 14 13:13:10 2024 +0200 easygit, lul. commit 429003c91aadba10e2447fab2a536d21cb1a334c Author: Harald Pfeiffer Date: Sun Jul 14 13:10:23 2024 +0200 solution in readme commit 3d3d8bf1736400f064dc25213bc38ea1f902ed25 Author: Harald Pfeiffer Date: Sun Jul 14 13:06:12 2024 +0200 final hook commit 784cca88b3ccfaf2e3ddc6d39b6b62da3e636b31 Author: Harald Pfeiffer Date: Sun Jul 14 12:58:16 2024 +0200 accident commit c93a9ef0252f7285f5bd8c0e5a60cde17c3ab1bd Author: Harald Pfeiffer Date: Sun Jul 14 12:57:36 2024 +0200 preparation for submodule-less checkout commit 0854d735ac6f596205df2484c9c5793cdf259e73 Author: Harald Pfeiffer Date: Sun Jul 14 12:18:40 2024 +0200 +pre-commit commit 00f87081a3ba50b48dc3cebfaa3c804e805120b0 Author: Harald Pfeiffer Date: Sun Jul 14 12:15:04 2024 +0200 add git-prompt to ignore list commit 574bbc70cc4282baee11a0548f0bb3d9510ddee9 Author: Harald Pfeiffer Date: Sun Jul 14 12:13:14 2024 +0200 remove from cache commit e60e29cb6c941223768634413e7ffa13cc5b0b19 Author: Harald Pfeiffer Date: Sun Jul 14 12:12:21 2024 +0200 move submodule git-prompt to post-checkout commit 738ecb82e946043914fc822d8fb877a655e5ad4f Author: Harald Pfeiffer Date: Sun Jul 14 11:57:52 2024 +0200 ... commit 672c91bc95a167269fb7ddfa2c84e4f7da2bdad2 Author: Harald Pfeiffer Date: Sun Jul 14 11:32:25 2024 +0200 here goes another attempt commit cbc3482c5d475eff579902004f81cefd38cfcb98 Author: Harald Pfeiffer Date: Sun Jul 14 10:53:38 2024 +0200 specify branch of submodule commit 95a8483b04efddab37aa92d52134a823ecc1920f Merge: 5155ed2 ce9a713 Author: Harald Pfeiffer Date: Sun Jul 14 10:52:21 2024 +0200 Merge between two machines (again) commit 5155ed2eefa29fc2d660823f8609e0c7dcc85113 Author: Harald Pfeiffer Date: Sun Jul 14 10:52:12 2024 +0200 reintroducing main submodule shllow/sparse config commit ce9a713662fdb8cc30eed9bdfb3a9fc9ab217afc Merge: b2b8209 717e60b Author: Harald Pfeiffer Date: Sun Jul 14 10:38:11 2024 +0200 Merge between two pulls and machines commit b2b82097d4e167b285abac53d0e6a291a4f798a7 Author: Harald Pfeiffer Date: Sun Jul 14 10:38:03 2024 +0200 +weird sha1collisiondetection submodule in README commit 717e60be83f2cf22808bc75ba37459e888a39513 Author: Harald Pfeiffer Date: Sun Jul 14 10:29:35 2024 +0200 working commit for submodule commit 11376154555ea0a325742d0d81dc282642837940 Author: Harald Pfeiffer Date: Sun Jul 14 10:18:41 2024 +0200 revamp commit aaf11ee32d35a194eb58387f4742cf00acadbbf2 Author: Harald Pfeiffer Date: Sun Jul 14 10:08:07 2024 +0200 fix: submodule info of git-prompt was garbage commit 8faef2071a0dd0358714b082738dbc253378214a Author: Harald Pfeiffer Date: Sun Jul 14 09:59:33 2024 +0200 inclusion of git prompt commit 9b850221308f64fe6e641555fcbd24ddf5a7ff7b Author: Harald Pfeiffer Date: Sun Jul 14 09:00:08 2024 +0200 integrate go binaries in $HOME into PATH commit 71b39d46de0bfe14b44f4241c8b8af01d3fb6b27 Author: Harald Pfeiffer Date: Sun May 26 10:52:50 2024 +0200 Updated submodules commit 37fdb2a700e47cc84f0dd3b004b33c41b1eb4abe Author: Harald Pfeiffer Date: Sun May 26 10:48:44 2024 +0200 + flake8's cognitive complexity commit 6922aa0ab8cfbdc83fc2a38fe486c9a390807c99 Author: Harald Pfeiffer Date: Sat May 25 13:27:52 2024 +0200 include tofu in gpg trust model commit e5abe8e6672cff7852c48f1db57176d9b03538f9 Author: Harald Pfeiffer Date: Sat May 25 13:27:15 2024 +0200 fwiw, return to whitespaces. more bytes, but more interoperability. commit d9b65ed059e81cca89bcec21545aa8816198537d Author: Harald Pfeiffer Date: Sat May 25 13:25:35 2024 +0200 only use the control master if desired. causes more fuss than solutions on daily use. commit badff375848d9af77e9761619f374278da862dac Author: Harald Pfeiffer Date: Sat May 25 13:24:03 2024 +0200 + credential helper, + memory window --- .bash/postexec.bash | 7 +++++++ .bash/prompt.bash | 14 +++++++++++++- .bash/vars.bash | 2 +- .flake8 | 2 ++ .gitconfig | 7 +++++++ .githooks/post-checkout | 13 +++++++++++++ .githooks/pre-commit | 4 ++++ .gitignore | 2 ++ .gitmodules | 3 +++ .gnupg/gpg.conf | 1 + .pylintrc | 2 +- .ssh/config.d/0000-all.conf | 4 ++-- README.md | 32 ++++++++++++++++++++++++++------ tmux-gpakosz | 2 +- tmux-yank | 2 +- 15 files changed, 84 insertions(+), 13 deletions(-) create mode 100755 .githooks/post-checkout create mode 100755 .githooks/pre-commit diff --git a/.bash/postexec.bash b/.bash/postexec.bash index 564356a..6137814 100644 --- a/.bash/postexec.bash +++ b/.bash/postexec.bash @@ -6,3 +6,10 @@ if [ -n "$SSHENVFILE" ] && [ -r "$SSHENVFILE" ];then fi fi fi +for gitpsrc in "/usr/share/git/git-prompt.sh" "/usr/local/share/git/git-prompt.sh" \ + "/usr/share/git-completion/prompt.sh" "/usr/local/share/git-completion/prompt.sh"; do + if [ -r "$gitpsrc" ]; then + source "$gitpsrc" + break + fi +done diff --git a/.bash/prompt.bash b/.bash/prompt.bash index 6914d63..8c4dbaa 100644 --- a/.bash/prompt.bash +++ b/.bash/prompt.bash @@ -145,7 +145,19 @@ __prompt_command() { PS1="\\# \[$(tput bold)\]\[$($FGC1)\]\t \[$($FGC2)\]\\u$UHSEP\[$($FGC3)\]$PHN \\w \[$(tput sgr0)\]\\n" ;; esac - if command -v __git_ps1 >/dev/null 2>&1;then PS1+="$(__git_ps1 "%s ")";fi + # git-completion. Sources: + # - https://github.com/git/git/tree/master/contrib/completion (main) + # - https://github.com/felipec/git-completion (fork) + # - Debian: easygit (outdated! you may want to use something like /git-prompt inside this repo) + # - Arch: git-completion (AUR, with functionality tests) - search for ...share/git(-completion)?/prompt.sh + # - Manual measure: this repository, /git-prompt + # Why all this fuss? magicmonty takes control over the whole prompt, __git_ps1 only serves a part + # of it. We don't like monoliths, we like modules; the latter is good practice. + # also, see postexec --> one-time sourcing of git's prompt.sh + if command -v __git_ps1 >/dev/null 2>&1;then + GIT_PS1_SHOWCOLORHINTS=1 + PS1+="$(__git_ps1 "%s ")" + fi if [ "$EXIT" -eq 0 ];then PS1+="\[\033[0;32m\]# " elif [ "$EXIT" -eq 255 ]||[ "$EXIT" -eq 127 ];then diff --git a/.bash/vars.bash b/.bash/vars.bash index da222b1..a7bdcb5 100644 --- a/.bash/vars.bash +++ b/.bash/vars.bash @@ -18,7 +18,7 @@ SSHAGH+=( "woschd.example.com" ) export SSHAGH # ----- SHELL ----- # -for pa in "/usr/local/bin" "${HOME}/bin" "${HOME}/.local/bin";do +for pa in "/usr/local/bin" "${HOME}/bin" "${HOME}/.local/bin" "${HOME}/go/bin";do if [ -x "$pa" ]; then if ! printf "%b" "$PATH"|grep -P "^${pa}:|:${pa}:" >/dev/null;then export PATH="${pa}:${PATH}" diff --git a/.flake8 b/.flake8 index c35b8d3..e6ad5fa 100644 --- a/.flake8 +++ b/.flake8 @@ -13,6 +13,8 @@ doctests = True # format = ${cyan}%(path)s${reset}:${yellow_bold}%(row)d${reset}:${green_bold}%(col)d${reset}:\\t${red_bold}%(code)s${reset} %(text)s # Superseding flake8-colors: format = %(cyan)s%(path)s%(reset)s:%(yellow)s%(bold)s%(row)d%(reset)s:%(green)s%(bold)s%(col)d%(reset)s: %(red)s%(bold)s%(code)s%(reset)s %(text)s +# python8-flake8-cognitive-complexity +max-cognitive-complexity = 16 #per-file-ignores = # # imported but unused # __init__.py: F401 diff --git a/.gitconfig b/.gitconfig index 5a312f4..440b155 100644 --- a/.gitconfig +++ b/.gitconfig @@ -73,6 +73,7 @@ [core] editor = vim fileMode = true + hooksPath = ~/git-hooks [merge] tool = vimdiff [mergetool] @@ -88,3 +89,9 @@ #proxy = http://10.0.0.1:3128/ [pull] rebase = false +[pack] + windowMemory = 1024m +[credential] + helper = !type pass-git-helper > /dev/null && pass-git-helper $@ + useHttpPath = true + diff --git a/.githooks/post-checkout b/.githooks/post-checkout new file mode 100755 index 0000000..e02dfcf --- /dev/null +++ b/.githooks/post-checkout @@ -0,0 +1,13 @@ +#!/usr/bin/env sh +rm -rf ./git-prompt +git -c submodule.sha1collisiondetection.update=none clone --no-checkout --depth 1 https://github.com/git/git.git ./git-prompt &&\ +( + cd ./git-prompt || exit 110 + #mkdir -pv contrib/completion || exit 111 + #git show HEAD:contrib/completion/git-prompt.sh > contrib/completion/git-prompt.sh || exit 112 + git restore --staged contrib/completion/git-prompt.sh + git checkout contrib/completion/git-prompt.sh + # if you can't cope with git reporting a truckload of deleted files, do this: + #rm -rf .git + # ...mind you this will alwasys pull in the whole repository on checkout/clone. +) diff --git a/.githooks/pre-commit b/.githooks/pre-commit new file mode 100755 index 0000000..2ec7e41 --- /dev/null +++ b/.githooks/pre-commit @@ -0,0 +1,4 @@ +#!/usr/bin/env sh +git config --remove-section submodule.git-prompt +printf "submodule git-prompt has been removed. After pushing, don't forget to trigger the" +printf " post-checkout hook again.\\n" diff --git a/.gitignore b/.gitignore index d049053..e9d033e 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,5 @@ !/.vimrc !/.ssh/config !/.ssh/config.d/0000-all.conf +#!/git-prompt +!/.githooks diff --git a/.gitmodules b/.gitmodules index d2a5366..9a9d797 100644 --- a/.gitmodules +++ b/.gitmodules @@ -6,3 +6,6 @@ path = tmux-yank url = https://github.com/tmux-plugins/tmux-yank branch = master +[submodule "git-prompt"] + path = git-prompt + url = https://github.com/git/git.git diff --git a/.gnupg/gpg.conf b/.gnupg/gpg.conf index 3b013a4..d91ecbd 100644 --- a/.gnupg/gpg.conf +++ b/.gnupg/gpg.conf @@ -11,3 +11,4 @@ cert-digest-algo SHA256 no-emit-version ask-cert-level expert +trust-model tofu+gpg diff --git a/.pylintrc b/.pylintrc index d66e5a2..92ee902 100644 --- a/.pylintrc +++ b/.pylintrc @@ -3,5 +3,5 @@ jobs=2 [FORMAT] -indent-string='\t' +#indent-string='\t' max-line-length=100 diff --git a/.ssh/config.d/0000-all.conf b/.ssh/config.d/0000-all.conf index df13d7c..7a69c2a 100644 --- a/.ssh/config.d/0000-all.conf +++ b/.ssh/config.d/0000-all.conf @@ -6,8 +6,8 @@ SendEnv LANG LC_* MUTTEXEC HashKnownHosts yes ForwardAgent yes -ControlMaster auto -ControlPath /run/user/%i/ssh/cm-%r@%h:%p +#ControlMaster auto +#ControlPath /run/user/%i/ssh/cm-%r@%h:%p # ControlMaster: to use SSH multiplexing with ProxyCommand (e.g. to reach host b through host a) # Host b diff --git a/README.md b/README.md index 6728444..e660979 100644 --- a/README.md +++ b/README.md @@ -4,10 +4,30 @@ Yet another (!) approach at building up a centralized configuration. Parts are old, parts are not done yet, we're getting there. -## To-Dos +# Information for cloning -* i3 config / sway config -* gpg config -* game launching stuff -* parallel-ssh and ansible -* ... +## only clone git-prompt.sh + +This repository does not include a git-prompt.sh source. This is due to the file residing inside +the whole git repository. Submoduling cannot just include one file, so if you need this file here, +the checkout is... up to you, kind of. + +Since I am maintaining this repo for ease of distribution for myself as well, here's the solution: + +Trigger `/.githooks/post-checkout` inside this repo. Either do this on any checkout, or set your git +post-checkout trigger for this file to automatically take over. + +## sha1collisiondetection + +For git-prompt, its submodule sha1collisiondetection may be "broken" (i.e. it cannot be pulled), here's a fix: + +`git -c submodule.sha1collisiondetection.update=none COMMAND` + +...whereas `COMMAND` is one of the usual actions such as + +``` +clone --recurse-submodules +submodule update --init --recursive +``` + +This only applies if you do not use `/.githooks/post-checkout` inside this repository. diff --git a/tmux-gpakosz b/tmux-gpakosz index b69ae7c..9cf4973 160000 --- a/tmux-gpakosz +++ b/tmux-gpakosz @@ -1 +1 @@ -Subproject commit b69ae7c1a4243afd02c5883a500c61218f6bbf3b +Subproject commit 9cf49731cd785b76cf792046feed0e8275457918 diff --git a/tmux-yank b/tmux-yank index 1b1a436..acfd36e 160000 --- a/tmux-yank +++ b/tmux-yank @@ -1 +1 @@ -Subproject commit 1b1a436e19f095ae8f825243dbe29800a8acd25c +Subproject commit acfd36e4fcba99f8310a7dfb432111c242fe7392 -- cgit v1.2.3