about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorDavid Morgan <djm_uk@protonmail.com>2022-11-18 12:12:57 +0000
committerDavid Morgan <djm_uk@protonmail.com>2022-11-18 12:12:57 +0000
commit55f64497a85304daa211c06957c4f01704a3912c (patch)
tree51354fafe18c83bd97fc79dbc70a3b5145d10a43
parent59dbe8806e428314db25c4a4bd9facd6bcb0bccf (diff)
downloaddotfiles-55f64497a85304daa211c06957c4f01704a3912c.tar.gz
Add git config
-rw-r--r--nix-conf/home/includes/common.nix77
-rw-r--r--nix-conf/home/otm.nix20
2 files changed, 97 insertions, 0 deletions
diff --git a/nix-conf/home/includes/common.nix b/nix-conf/home/includes/common.nix
index 5d64c5a..9deaaf6 100644
--- a/nix-conf/home/includes/common.nix
+++ b/nix-conf/home/includes/common.nix
@@ -26,6 +26,7 @@ in
     bottom
     broot
     curl
+    diff-so-fancy
     difftastic
     duf
     du-dust
@@ -167,5 +168,81 @@ in
       };
     };
   };
+
+  programs.git = {
+    enable = true;
+    userName = "David Morgan";
+    aliases = {
+      # difftastic
+      logt = "!sh -c 'GIT_EXTERNAL_DIFF=\"difft --background=dark\" git log -p --ext-diff'";
+      showt = "!show() { GIT_EXTERNAL_DIFF=difft git show \${1} --ext-diff; }; show";
+      difft = "difftool";
+      # "raw" output
+      rlog = "!git -c delta.raw=true -c core.pager=${pkgs.less}/bin/less log"; # usually used with -p
+      rshow = "!git -c delta.raw=true -c core.pager=${pkgs.less}/bin/less show";
+      rdiff = "!git -c delta.raw=true -c core.pager=${pkgs.less}/bin/less diff";
+      #  copiable output (without line numbers or +/- indicators)
+      clog = "!git -c delta.line-numbers=false log"; # usually used with -p
+      cshow = "!git -c delta.line-numbers=false show";
+      cdiff = "!git -c delta.line-numbers=false diff";
+      # diff-so-fancy
+      flog = "!git -c core.pager=\"diff-so-fancy | less\" log"; # usually used with -p
+      fshow = "!git -c core.pager=\"diff-so-fancy | less\" show";
+      fdiff = "!git -c core.pager=\"diff-so-fancy | less\" diff";
+
+      upstream = "!git push -u origin HEAD";
+      update-master = "!git fetch origin master:master";
+      update-main = "!git fetch origin main:main";
+    };
+    extraConfig = {
+      core.editor = "vim";
+      diff = {
+        tool = "difftastic";
+        colorMoved = "default";
+      };
+      difftool = {
+        prompt = false;
+        difftastic = { cmd = ''difft "$LOCAL" "$REMOTE"''; };
+      };
+      merge = {
+        conflictstyle = "diff3";
+        ff = "only";
+      };
+      pull = {
+        ff = "only";
+        rebase = false;
+      };
+      push.autoSetupRemove = true;
+      rebase = {
+        # TODO
+        # autosquash = true;
+        autostash = true;
+      };
+    };
+    delta = {
+      enable = true;
+      options = {
+        line-numbers = true;
+        navigate = true;
+        light = false;
+        file-style = "bold yellow ul";
+        hunk-header-line-number-style = "brightyellow";
+      };
+    };
+    ignores = [
+      ".lein-repl-history"
+      ".lsp"
+      ".rebel_readline_history"
+      ".cider-repl-history"
+      "nohup.out"
+      "*.elc"
+      "*.eln"
+      "*~"
+    ];
+    signing = {
+      key = "9B436B1477A879C26CDB6604C171251002C200F2";
+      signByDefault = true;
+    };
+  };
 }
 
diff --git a/nix-conf/home/otm.nix b/nix-conf/home/otm.nix
index c79437b..1065852 100644
--- a/nix-conf/home/otm.nix
+++ b/nix-conf/home/otm.nix
@@ -12,6 +12,26 @@
   home.username = "djm";
   home.homeDirectory = "/Users/djm";
 
+  programs.git = {
+    signing.signByDefault = lib.mkForce false;
+    includes = [
+      { path = "~/.gitconfig-personal"; condition = "gitdir:~/src/personal/"; }
+      { contents = { commit.gpg = true; }; condition = "gitdir:~/src/personal/"; }
+    ];
+    extraConfig = {
+      github.user = "david-morgan-otm";
+    };
+    ignores = [
+      ".envrc"
+      ".clj-kondo"
+      "shell.nix"
+      ".direnv"
+      ".dir-locals.el"
+      "browser-tests/package-lock.json"
+      "resources/react-app/package-lock.json"
+      "resources/next/package-lock.json"
+    ];
+  };
   programs.ssh.matchBlocks = {
     "github.com" = lib.mkForce {
       hostname = "github.com";