Skip to content

Instantly share code, notes, and snippets.

@qtfkwk
Last active November 7, 2023 15:02
Show Gist options
  • Save qtfkwk/9aaca5cd0ae5337022ba215724fdbac3 to your computer and use it in GitHub Desktop.
Save qtfkwk/9aaca5cd0ae5337022ba215724fdbac3 to your computer and use it in GitHub Desktop.
Git configuration file
[alias]
d = diff --color=always
dc = d --cached
dcw = d --cached --word-diff=color
dw = d --word-diff=color
dwc = d --word-diff=color --cached
s = status
l = log --show-signature --stat --numstat
ln = log --show-signature --name-status --stat --numstat
lp = log --show-signature -p --stat --numstat
lpr = log --show-signature -p --reverse --stat --numstat
c = commit -S
sign-last = commit --amend -S
lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --no-show-signature
lgr = log --color --reverse --pretty=format:'* %Cred%h%Creset %s' --abbrev-commit --no-show-signature
lgn = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --name-status --no-show-signature
lmt = "!f() { git-lmt.sh; }; f"
g = log --oneline --abbrev-commit --graph --decorate --all --date-order --no-show-signature
gr = log --oneline --abbrev-commit --reverse --decorate --all --date-order --no-show-signature
r = "!f(){ git rebase -i $(git rev-parse $(git remote -v |grep push |head -1 |awk '{print $1}')/$(git rev-parse --abbrev-ref HEAD)); }; f"
g10 = g -n 10
lg10 = lg -n 10
db = "!f(){ git diff --name-only --diff-filter=d $@ |xargs bat --diff; }; f"
[core]
excludesfile = ~/.gitignore
[push]
default = simple
[user]
name =
email =
signingkey =
[commit]
gpgsign = false
[log]
showSignature = true
[filter "lfs"]
process = git-lfs filter-process
required = true
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
[init]
defaultBranch = main
[pull]
rebase = false
#!/usr/bin/env bash
set -eo pipefail
git_lmt() {
F="%a %Y-%m-%d %H:%M:%SZ"
r() {
IFS="|"
read -ra A <<< "$1"
C="${A[0]}"
H="${A[1]}"
M="${A[2]}"
if [ -z "$L" ]; then D=0; else D=$((C-L)); fi
S=$((S+D))
T=$(date -ud "@$C" "+$F")
printf "%24s | %8s | %10s | %7s | %s\n" "$T" "$D" "$S" "$H" "$M"
L=$C
}
S=0
cat <<EOF
Timestamp | Duration | Total time | Commit | Message
-------------------------|---------:|-----------:|---------|--------------------
EOF
while IFS= read -r line; do r "$line"; done \
< <(git log --reverse --pretty=format:'%ct|%h|%s' --no-show-signature)
r "$line"
}
git_lmt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment