Skip to content

Instantly share code, notes, and snippets.

@jdb8
Last active October 3, 2019 06:26
Show Gist options
  • Save jdb8/efd366906c9237f3101b2b4092186739 to your computer and use it in GitHub Desktop.
Save jdb8/efd366906c9237f3101b2b4092186739 to your computer and use it in GitHub Desktop.
Thin wrapper around git, which could be extended to monkeypatch other small parts of git itself where it's not feasible to impose these changes on other devs working on the same repos.
#!/usr/bin/env bash
set -euo pipefail
# Disgusting wrapper around git, which prevents `git clean -fdX` from removing
# any .vscode folder that exists in the repo (by moving it to a different path
# and back again). I don't want to check the
# .vscode folder into git, but I also don't want it to be removed. Apart from that,
# git clean -fdX works well as a `make clean` target!
if [ "$1" = "clean" ]; then
if [ -d ".vscode" ]; then
DATA_DIR=${XDG_DATA_HOME-$HOME/.local/share}
TARGET="$DATA_DIR/.___vscode__backup___"
mkdir -p "$TARGET"
mv ".vscode" "$TARGET"
function move_back {
mv "$TARGET" ".vscode"
}
trap move_back EXIT
fi
fi
/usr/bin/git "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment