manage git with chezmoi

This commit is contained in:
js0ny 2025-10-20 03:44:56 +01:00
parent e3a0205724
commit 52b70819bf
19 changed files with 204 additions and 104 deletions

17
home/.chezmoi.toml.tmpl Normal file
View file

@ -0,0 +1,17 @@
{{/* https://github.com/twpayne/dotfiles/blob/master/home/.chezmoi.toml.tmpl */}}
{{- $headless := false -}}
{{/* darwin hostname hack */}}
{{- $hostname := .chezmoi.hostname -}}
{{- if eq .chezmoi.os "darwin" -}}
{{- $hostname := output "scutil" "--get" "LocalHostName" | trim -}}
{{- end -}}
sourceDir = "~/.dotfiles"
{{ $email := promptStringOnce . "email" "What is your email address" -}}
{{ $username := promptStringOnce . "username" "What is your username" -}}
[data]
email = {{ $email | quote }}
username = {{ $username | quote }}

View file

@ -27,14 +27,17 @@ scripts
{{ end }}
{{ if eq .chezmoi.osRelease.id "nixos" }}
.config/bash
.config/fcitx5
.config/bat
.config/doom
.config/dunst
.config/fastfetch
.config/fcitx5
.config/fish
.config/zsh
.config/lsd
.config/keyd
.config/readline
.config/krunnerrc
.bashrc
{{ end }}
{{ end }}
@ -47,3 +50,7 @@ Library
.config/yabai
.config/powershell
{{ end }}
{{ if ne .chezmoi.os "windows" }}
.gitconfig
{{ end }}

View file

@ -0,0 +1,75 @@
# $DOTFILES/common/gitconfig.example
# Date: 2024-12-22
# Author: js0ny
# Location:
# Windows: %USERPROFILE%\.gitconfig
# *nix: ~/.config/git/config
# Linking: (Note that this file is an example, only copy this then edit)
# cp $DOTFILES/common/gitconfig.example ~/.config/git/config
[user]
name = {{ .username }}
email = {{ .email }}
[alias]
cl = clone
clnh = clone --depth 1 # Clone with no history
cma = commit -am # Add and commit
logs = log --oneline --graph --decorate --all # Show logs
last = log -1 HEAD # Show last commit
undo = reset --hard HEAD # Undo the last commit
[core]
editor = nvim
pager = delta
# autocrlf:
# true: Keep crlf in Windows, lf in *nix
# input: Keep lf in all platforms
autocrlf = input
safecrlf = true
excludesfile = $XDG_CONFIG_HOME/git/ignore
quotePath = false # zh-CN: 解决中文路径问题
eol = lf
[core]
{{- if eq .chezmoi.os "windows" }}
editor = vim
{{- else }}
editor = nvim
{{- end }}
pager = delta
autocrlf = input # Force End of Line in different platforms
[interactive]
diffFilter = delta --color-only
[delta]
navigate = true
dark = true
features = catppuccin-mocha # Colorscheme
[diff]
tool = nvimdiff
[difftool]
prompt = false
[difftool "nvimdiff"]
cmd = "nvim -d \"$LOCAL\" \"$REMOTE\""
[merge]
tool = nvimdiff
[mergetool]
prompt = false
[mergetool "nvimdiff"]
cmd = "nvim -d \"$LOCAL\" \"$MERGED\" \"$REMOTE\""
[color]
ui = auto
[pull]
ff = only
[init]
defaultBranch = master
[filter "lfs"]
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
process = git-lfs filter-process
required = true
# Force ssh
# Don't use ssh in GitHub since ssh-agent doesn't work in non-interactive environment
# While GitHub holds many plugins, it's better to use https
# This prevents from Neovide `publickey` error when installing plugins
# [url "git@github.com:"]
# insteadOf = https://github.com/
[url "git@codeberg.org:"]
insteadOf = https://codeberg.org/

View file

@ -0,0 +1 @@
{{ includeTemplate "dot_config/git/_gitconfig.shared.tmpl" . }}

View file

@ -20,30 +20,17 @@ source ~/.local/share/intellimacs/which-key.vim
let mapleader = " " " set <leader> to <space>
""" Colemak """
noremap n j
noremap e k
noremap i l
" Similar position to i
noremap l i
noremap L I
" ne[k]st
noremap k n
noremap K N
" [j]ump
noremap j e
noremap J E
nnoremap H :bp<CR>
nnoremap I :bn<CR>
noremap N 5j
noremap E 5k
nnoremap L :bn<CR>
noremap J 5j
noremap K 5k
vnoremap H ^
xnoremap H ^
onoremap H ^
vnoremap I $
xnoremap I $
onoremap I $
vnoremap L $
xnoremap L $
onoremap L $
@ -221,9 +208,9 @@ nnoremap <leader>W :write<CR>
nnoremap <leader>wh :action PrevSplitter<CR>
nnoremap <leader>wi :action NextSplitter<CR>
nnoremap <leader>wH :action SplitHorizontally<CR>
nnoremap <leader>wI :action SplitHorizontally<CR>
nnoremap <leader>wN :action SplitVertically<CR>
nnoremap <leader>wE :action SplitVertically<CR>
nnoremap <leader>wL :action SplitHorizontally<CR>
nnoremap <leader>wJ :action SplitVertically<CR>
nnoremap <leader>wK :action SplitVertically<CR>
nnoremap <leader>w- :action SplitHorizontally<CR>
nnoremap <leader>w| :action SplitVertically<CR>
nnoremap <leader>w\ :action SplitVertically<CR>

View file

@ -1,9 +1,11 @@
# Colors
default-timeout=5000
background-color=#1e1e2e
text-color=#cdd6f4
border-color=#b4befe
progress-color=over #313244
max-visible=10
[urgency=high]
border-color=#fab387

1
home/dot_gitconfig Normal file
View file

@ -0,0 +1 @@
{{ includeTemplate "dot_config/git/_gitconfig.shared.tmpl" . }}