feat(git): add ignore aliases
All checks were successful
Discord / discord commits (push) Has been skipped

This commit is contained in:
matt1432 2025-01-24 18:38:07 -05:00
parent 9af0b7f86a
commit 9d060c9f52

View file

@ -4,7 +4,7 @@ self: {
pkgs, pkgs,
... ...
}: let }: let
inherit (lib) mkIf; inherit (lib) getExe mkIf;
cfg = config.programs.bash; cfg = config.programs.bash;
@ -13,6 +13,8 @@ self: {
contents.user = {inherit email name;}; contents.user = {inherit email name;};
}; };
mkDefaultRemote = remote: mkRemoteConf remote "matt@nelim.org" "matt1432"; mkDefaultRemote = remote: mkRemoteConf remote "matt@nelim.org" "matt1432";
mkGitAlias = script: "!${getExe script}";
in { in {
config.programs = mkIf cfg.enable { config.programs = mkIf cfg.enable {
git = { git = {
@ -40,6 +42,48 @@ in {
}; };
extraConfig = { extraConfig = {
alias = {
# https://stackoverflow.com/a/18317425
ignore = "update-index --assume-unchanged";
unignore = "update-index --no-assume-unchanged";
ignored = "!git ls-files -v | ${getExe pkgs.gnugrep} \"^[[:lower:]]\"";
untracked-ignore = mkGitAlias (pkgs.writeShellApplication {
name = "untracked-ignore";
text = ''
if [ $# -eq 0 ]; then
echo "No file names provided"
exit 1
fi
for arg in "$@"; do
echo -e "$arg\n" >> .git/info/exclude
done
'';
});
untracked-unignore = mkGitAlias (pkgs.writeShellApplication {
name = "untracked-unignore";
text = ''
if [ $# -eq 0 ]; then
echo "No file names provided"
exit 1
fi
for arg in "$@"; do
sed -i "s/$arg//" .git/info/exclude
done
'';
});
untracked-ignored = mkGitAlias (pkgs.writeShellApplication {
name = "untracked-ignored";
text = ''
while IFS= read -r line; do
if [[ "$line" != "" ]] && [[ "$line" != "#"* ]]; then
echo "$line"
fi
done < .git/info/exclude
'';
});
};
diff.sopsdiffer.textconv = "sops --config /dev/null -d"; diff.sopsdiffer.textconv = "sops --config /dev/null -d";
# https://github.com/dandavison/delta/issues/630#issuecomment-860046929 # https://github.com/dandavison/delta/issues/630#issuecomment-860046929