114 lines
4.0 KiB
Nix
114 lines
4.0 KiB
Nix
{ config, pkgs, lib, ... }:
|
|
{
|
|
home.packages = with pkgs; [
|
|
#git
|
|
gh
|
|
git-wait
|
|
#hub
|
|
(pkgs.symlinkJoin {
|
|
inherit (pkgs.hub) name meta;
|
|
paths = [ pkgs.hub ];
|
|
# TODO: this could be a pre-command added with makeWrapper
|
|
postBuild = ''
|
|
rm $out/bin/hub
|
|
cat <<"EOF" >$out/bin/hub
|
|
#!${pkgs.runtimeShell}
|
|
|
|
# https://hub.github.com/hub.1.html#github-oauth-authentication
|
|
if [[ ! -d ~/.config/hub ]]; then
|
|
export GITHUB_TOKEN=$(${pkgs.gh}/bin/gh auth token 2>/dev/null)
|
|
fi
|
|
|
|
exec -a "$0" ${pkgs.hub}/bin/hub "$@"
|
|
EOF
|
|
chmod +x $out/bin/hub
|
|
'';
|
|
})
|
|
|
|
tea
|
|
colordiff
|
|
diffnav
|
|
];
|
|
|
|
#programs.gh.enable = true; # adds read-only config to .config
|
|
|
|
#programs.git.gitui.enable = true;
|
|
programs.git.enable = true;
|
|
programs.git.lfs.enable = true;
|
|
programs.git.delta.enable = true;
|
|
programs.git.delta.options = {
|
|
# Delta uses ~/.gitconfig even when not invoked by git
|
|
tabs = 4;
|
|
max-line-length = 0;
|
|
features.syntax-theme = lib.mkIf config.programs.bat.enable config.programs.bat.config.theme;
|
|
};
|
|
#programs.git.lfs.enable = true;
|
|
#programs.git.signing
|
|
#programs.git.userName = "pbsds"
|
|
programs.git.userName = "Peder Bergebakken Sundt";
|
|
programs.git.userEmail = "pbsds@hotmail.com";
|
|
|
|
# https://jvns.ca/blog/2024/02/16/popular-git-config-options/
|
|
programs.git.extraConfig.rerere.enabled = true;
|
|
#programs.git.extraConfig.help.autocorrect = "prompt";
|
|
programs.git.extraConfig.transfer.fsckobjects = true;
|
|
programs.git.extraConfig.fetch.fsckobjects = true;
|
|
programs.git.extraConfig.receive.fsckObjects = true;
|
|
programs.git.extraConfig.branch.sort = "-committerdate";
|
|
programs.git.extraConfig.tag.sort = "taggerdate";
|
|
programs.git.extraConfig.fetch.prune = true;
|
|
programs.git.extraConfig.fetch.prunetags = true;
|
|
programs.git.extraConfig.log.date = "iso";
|
|
/* programs.git.extraConfig.interactive.singleKey = true; */
|
|
|
|
programs.git.iniContent.init.defaultBranch = "main";
|
|
programs.git.ignores = [
|
|
#".envrc"
|
|
".direnv"
|
|
".remote.toml"
|
|
".remoteenv"
|
|
".zed"
|
|
"result"
|
|
"result-*"
|
|
"results"
|
|
"results-*"
|
|
"__pycache__"
|
|
"*.pyc"
|
|
];
|
|
|
|
home.shellAliases = {
|
|
# git gud
|
|
gs = "git status";
|
|
gl = "git --no-pager log --oneline --color -n30";
|
|
glg = "git log --color --all --decorate --oneline --graph";
|
|
gpra = "git pull --rebase --autostash";
|
|
gprau = ''git pull --rebase --autostash upstream "$(git branch 2>/dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/')"'';
|
|
gd = "git diff";
|
|
gds = "git diff --staged";
|
|
gdwd = "git -c core.pager=\"$PAGER\" diff --word-diff"; # delta does not support --word-diff
|
|
gdwdr = "git -c core.pager=\"$PAGER\" diff --word-diff --word-diff-regex=.";
|
|
gdwds = "git -c core.pager=\"$PAGER\" diff --staged --word-diff";
|
|
gdswd = "git -c core.pager=\"$PAGER\" diff --staged --word-diff";
|
|
gdwdrs = "git -c core.pager=\"$PAGER\" diff --staged --word-diff --word-diff-regex=.";
|
|
gdswdr = "git -c core.pager=\"$PAGER\" diff --staged --word-diff --word-diff-regex=.";
|
|
#gcp = "git cherry-pick";
|
|
gca = "git commit --amend";
|
|
gcara = "git commit --amend --reset-author";
|
|
gc = "git branch | cut -c2- | gum choose | xargs -n'\n' --no-run-if-empty git checkout";
|
|
gbrm = "git fetch origin; git branch --merged | cut -c3- | grep -vE '^(main|master)$' | gum choose --no-limit --header 'Which branches to delete:' | xargs -n'\n' --no-run-if-empty git branch -D";
|
|
#gb = "git blame";
|
|
#gpo = "git push origin";
|
|
#gpf = "git push --force-with-lease --force-if-includes";
|
|
|
|
# TODO: use -c commit.template instead
|
|
gcm = ''git commit --message "$(printf '%s\n' ${lib.concatStringsSep " " [
|
|
''"$(curl -sL https://whatthecommit.com/index.txt)"''
|
|
''""''
|
|
''"$(curl -s 'https://printerfacts.cetacean.club/fact')"''
|
|
''""''
|
|
''"(made with https://whatthecommit.com/index.txt and https://printerfacts.cetacean.club/fact)"''
|
|
]})"; git show --name-status; '';
|
|
};
|
|
|
|
}
|