Add configuration for git
- Add .config/git/config + Define aliases + Configure default behavior in various situations + Add user information with signing key - Add .config/git/commit_msg_template.txt - Add .config/git/ignore - Integrate `git` aliases into the shell
This commit is contained in:
parent
3017a7bdec
commit
721c2fd905
21 changed files with 1122 additions and 66 deletions
46
.local/bin/git-clean-ignored
Executable file
46
.local/bin/git-clean-ignored
Executable file
|
|
@ -0,0 +1,46 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Remove all files ignored by `git`, except the ones listed in $KEEP below
|
||||
#
|
||||
# `git clean` does not accept "-e" together with "-X",
|
||||
# so the files to be kept are moved aside and then restored
|
||||
#
|
||||
# Usage: git clean-ignored [<git clean options>]
|
||||
|
||||
set -eu
|
||||
|
||||
|
||||
# Keep this list in sync with the other two copies:
|
||||
# - the "-e" flags of `clean-untracked` in ~/.config/git/config
|
||||
# - the preview in ~/.local/bin/git-clean-all
|
||||
KEEP=".env .python-version"
|
||||
|
||||
SUFFIX=".git-clean-ignored.bak"
|
||||
|
||||
|
||||
# `git` runs scripts on the `$PATH` in the current directory,
|
||||
# whereas it runs "!" aliases at the top level of the repository
|
||||
cd "$(git rev-parse --show-toplevel)"
|
||||
|
||||
|
||||
_restore() {
|
||||
for _file in $KEEP; do
|
||||
if [ -f "$_file$SUFFIX" ]; then
|
||||
mv "$_file$SUFFIX" "$_file"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
# Restore the kept files even if `git clean` fails or the user aborts
|
||||
trap _restore EXIT HUP INT TERM
|
||||
|
||||
|
||||
for _file in $KEEP; do
|
||||
if [ -f "$_file" ]; then
|
||||
mv "$_file" "$_file$SUFFIX"
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
git clean -X -d -f "$@"
|
||||
Loading…
Reference in a new issue