Add git-exclude
A Git commit that easily excludes files by adding them to `.git/info/exclude`.
This commit is contained in:
parent
a620888277
commit
d4e5faf6c4
3 changed files with 26 additions and 0 deletions
24
packages/git-exclude.nix
Normal file
24
packages/git-exclude.nix
Normal file
|
@ -0,0 +1,24 @@
|
|||
{ pkgs }:
|
||||
|
||||
pkgs.writeShellApplication {
|
||||
name = "git-exclude";
|
||||
|
||||
runtimeInputs = with pkgs; [ git ];
|
||||
|
||||
text = ''
|
||||
# Based on https://github.com/jfly/snow/blob/fb727b39736666f54908f4dc7c83dd6284607c5a/machines/pattern/homies/bin/git-exclude.
|
||||
|
||||
root=$(git rev-parse --show-toplevel)
|
||||
rel=$(realpath --relative-to "$root" .)
|
||||
|
||||
# For some reason, ignore rules like "./.envrc" don't seem to work, but
|
||||
# "/.envrc" does. :shrug:
|
||||
if [ "$rel" = "." ]; then
|
||||
rel=""
|
||||
fi
|
||||
|
||||
for item in "$@"; do
|
||||
echo "''${rel}/$item" >> "$root/.git/info/exclude"
|
||||
done
|
||||
'';
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue