NixOS-Configs/home/common/git.nix
2024-05-28 06:56:57 -05:00

318 lines
13 KiB
Nix

{ pkgs, config, ... }:
{
programs.lazygit = {
settings = {
os.editPreset = "lvim";
};
};
programs.git = {
enable = true;
aliases = {
co = "checkout";
br = "branch";
ci = "commit";
st = "status";
last = "cat-file commit HEAD";
};
diff-so-fancy = {
enable = true;
};
extraConfig = {
core = {
user = "Don Harper";
email = "duck@duckland.org";
editor = "${pkgs.neovim}/bin/nvim";
};
safe = {
directory = "*";
};
status = {
submoduleSummary = "true";
short = "true";
};
user = {
name = "Don Harper";
email = "duck@duckland.org";
};
push = {
default = "simple";
};
pull = {
rebase = "false";
};
git-extras = {
github-personal-access-token = "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";
};
fetch = {
prune = "true";
};
init = {
defaultBranch = "main";
};
credential = {
"https://github.com" = {
helper = "!${pkgs.gh}/bin/gh auth git-credential";
};
"https://gist.github.com" = {
helper = "!${pkgs.gh}/bin/gh auth git-credential";
};
};
};
};
xdg.configFile."tig/config".text = ''
set blame-view = date:default author:full file-name:auto id:yes line-number:no,interval=5 text
set grep-view = file-name:no line-number:yes,interval=1 text
set main-view = line-number:no,interval=5 id:no date:default author:full commit-title:yes,graph,refs,overflow=no
set refs-view = line-number:no id:no date:default author:full ref commit-title
set stash-view = line-number:no,interval=5 id:no date:default author:full commit-title
set status-view = line-number:no,interval=5 status:short file-name
set tree-view = line-number:no,interval=5 mode author:full file-size date:default id:no file-name
set pager-view = line-number:no,interval=5 text
set stage-view = line-number:no,interval=5 text
set log-view = line-number:no,interval=5 text
set blob-view = line-number:no,interval=5 text
set diff-view = line-number:no,interval=5 text:yes,commit-title-overflow=no
set show-changes = yes # Show changes commits in the main view?
set wrap-lines = no # Wrap long lines in pager views?
set tab-size = 8 # Number of spaces to use when expanding tabs
set line-graphics = default # Enum: ascii, default, utf-8
set truncation-delimiter = ~ # Character drawn for truncations, or "utf-8"
set reference-format = [branch] <tag> {remote} ~replace~
set commit-order = auto # Enum: auto, default, topo, date, reverse (main)
set status-show-untracked-dirs = yes # Show files in untracked directories? (status)
set status-show-untracked-files = yes # Show untracked files?
set ignore-space = no # Enum: no, all, some, at-eol (diff)
set show-notes = yes # When non-bool passed as `--show-notes=...` (diff)
set refresh-mode = auto # Enum: manual, auto, after-command, periodic
set refresh-interval = 10 # Interval in seconds between refreshes
set ignore-case = no # Enum: no, yes, smart-case
set wrap-search = yes # Wrap around to top/bottom of view when searching
set focus-child = yes # Move focus to child view when opened?
set horizontal-scroll = 50% # Number of columns to scroll as % of width
set split-view-height = 67% # Height of the bottom view for horizontal splits
set vertical-split = auto # Enum: horizontal, vertical, auto; Use auto to
set split-view-width = 50% # Width of right-most view for vertical splits
set editor-line-number = yes # Automatically pass line number to editor? Used
set history-size = 500 # Size of persistent history, 0 to disable
set mouse = no # Enable mouse support?
set mouse-scroll = 3 # Number of lines to scroll via the mouse
set mouse-wheel-cursor = no # Prefer moving the cursor to scrolling the view?
bind main C ?git cherry-pick %(commit)
bind status C !git commit
bind stash A ?git stash apply %(stash)
bind stash P ?git stash pop %(stash)
bind stash ! ?git stash drop %(stash)
bind refs C ?git checkout %(branch)
bind refs ! ?git branch -D %(branch)
bind generic m view-main
bind generic d view-diff
bind generic l view-log
bind generic t view-tree
bind generic f view-blob
bind generic b view-blame
bind generic r view-refs
bind generic p view-pager
bind generic h view-help
bind generic s view-status
bind generic S view-status # Compat binding to avoid going crazy!
bind generic c view-stage
bind generic y view-stash
bind generic g view-grep
bind generic <Enter> enter # Enter and open selected entry
bind generic <Lt> back # Go back to the previous view state
bind generic <Down> next # Move to next
bind generic <C-N> next
bind generic J next
bind generic <Up> previous # Move to previous
bind generic <C-P> previous
bind generic K previous
bind generic , parent # Move to parent
bind generic <Tab> view-next # Move focus to the next view
bind generic R refresh # Reload and refresh view
bind generic <F5> refresh
bind generic O maximize # Maximize the current view
bind generic q view-close # Close the current view
bind generic Q quit # Close all views and quit
bind generic <C-C> quit # Close all views and quit
bind status u status-update # Stage/unstage changes in file
bind status ! status-revert # Revert changes in file
bind status M status-merge # Open git-mergetool(1)
bind stage u status-update # Stage/unstage current diff (c)hunk
bind stage 1 stage-update-line # Stage/unstage current line
bind stage ! status-revert # Revert current diff (c)hunk
bind stage \ stage-split-chunk # Split current diff (c)hunk
bind stage @ :/^@@ # Jump to next (c)hunk
bind stage [ :toggle diff-context -1 # Decrease the diff context
bind stage ] :toggle diff-context +1 # Increase the diff context
bind diff @ :/^@@ # Jump to next (c)hunk
bind diff [ :toggle diff-context -1
bind diff ] :toggle diff-context +1
bind main G :toggle commit-title-graph # Toggle revision graph visualization
bind main F :toggle commit-title-refs # Toggle reference display (tags/branches)
bind generic j move-down
bind generic k move-up
bind generic <C-D> move-half-page-down
bind generic <C-U> move-half-page-up
bind generic <PgDown> move-page-down
bind generic <Space> move-page-down
bind generic <PgUp> move-page-up
bind generic - move-page-up
bind generic <Home> move-first-line
bind generic <End> move-last-line
bind generic | scroll-first-col
bind generic <Left> scroll-left
bind generic <Right> scroll-right
bind generic <Ins> scroll-line-up
bind generic <C-Y> scroll-line-up
bind generic <Del> scroll-line-down
bind generic <C-E> scroll-line-down
bind generic <SBack> scroll-page-up
bind generic <SFwd> scroll-page-down
bind generic / search
bind generic ? search-back
bind generic n find-next
bind generic N find-prev
bind search <Down> find-next
bind search <C-N> find-next
bind search <C-J> find-next
bind search <Up> find-prev
bind search <C-P> find-prev
bind search <C-K> find-prev
bind search <C-C> view-close
bind generic o options # Open the options menu
bind generic I :toggle sort-order # Toggle ascending/descending sort order
bind generic i :toggle sort-field # Toggle field to sort by
bind generic <Hash> :toggle line-number # Toggle line numbers
bind generic D :toggle date # Toggle date display
bind generic A :toggle author # Toggle author display
bind generic ~ :toggle line-graphics # Toggle (line) graphics mode
bind generic F :toggle file-name # Toggle file name display
bind generic W :toggle ignore-space # Toggle ignoring whitespace in diffs
bind generic X :toggle id # Toggle commit ID display
bind generic $ :toggle commit-title-overflow
bind generic % :toggle file-filter
bind generic e edit # Open in editor
bind generic : prompt # Open the prompt
bind generic <C-L> screen-redraw # Redraw the screen
bind generic z stop-loading # Stop all loading views
bind generic v show-version # Show Tig version
color "---" default default
color "diff --" default default
color "--- " default default
color "+++ " default default
color "@@" default default
color "+" default default
color " +" default default
color "-" default default
color " -" default default
color "index " default default
color "old file mode " default default
color "new file mode " default default
color "deleted file mode " default default
color "copy from " default default
color "copy to " default default
color "rename from " default default
color "rename to " default default
color "similarity " default default
color "dissimilarity " default default
color "diff-tree " default default
color "Author: " default default
color "Commit: " default default
color "Tagger: " default default
color "Merge: " default default
color "Date: " default default
color "AuthorDate: " default default
color "CommitDate: " default default
color "TaggerDate: " default default
color "Refs: " default default
color "Reflog: " default default
color "Reflog message: " default default
color "stash@{" default default
color "commit " default default
color "parent " default default
color "tree " default default
color "author " default default
color "committer " default default
color " Signed-off-by" default default
color " Acked-by" default default
color " Tested-by" default default
color " Reviewed-by" default default
color default default default normal
color cursor yellow default bold
color status default default
color delimiter default default
color date default default
color mode default default
color id default default
color overflow default default
color header default default
color section default default
color directory default default
color file default default
color grep.file default default
color file-size default default
color line-number default default
color title-blur default default
color title-focus default default bold
color main-commit default default
color main-tag default default bold
color main-local-tag default default
color main-remote default default
color main-replace default default
color main-tracked default default bold
color main-ref default default
color main-head default default bold
color stat-none default default
color stat-staged default default
color stat-unstaged default default
color stat-untracked default default
color help-group default default
color help-action default default
color diff-stat default default
color diff-add-highlight default default standout
color diff-del-highlight default default standout
color palette-0 default default
color palette-1 default default
color palette-2 default default
color palette-3 default default
color palette-4 default default
color palette-5 default default
color palette-6 default default
color palette-7 default default bold
color palette-8 default default bold
color palette-9 default default bold
color palette-10 default default bold
color palette-11 default default bold
color palette-12 default default bold
color palette-13 default default bold
color graph-commit default default
color search-result default default
set git-colors = \
branch.current=main-head \
branch.local=main-ref \
branch.plain=main-ref \
branch.remote=main-remote \
\
diff.meta=diff-header \
diff.meta=diff-index \
diff.meta=diff-oldmode \
diff.meta=diff-newmode \
diff.frag=diff-chunk \
diff.old=diff-del \
diff.new=diff-add \
\
diff-highlight.oldHighlight=diff-del-highlight \
diff-highlight.newHighlight=diff-add-highlight \
\
grep.filename=grep.file \
grep.linenumber=grep.line-number \
grep.separator=grep.delimiter \
\
status.branch=status.header \
status.added=stat-staged \
status.updated=stat-staged \
status.changed=stat-unstaged \
status.untracked=stat-untracked
'';
}