-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgit.bash
executable file
·65 lines (57 loc) · 2.46 KB
/
git.bash
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#! /usr/bin/env bash
_red="$(tput setaf 1 || tput AF 1)"
_res="$(tput sgr0 || tput me)"
if ! command -v git >/dev/null 2>&1
then
echo "${_red}git not found. abort.${_res}" 1>&2
exit 1
fi
git config --global user.name 'Dimitar Dimitrov'
git config --global init.defaultBranch main
git config --global color.ui true
# mitigate issues when pulling force-pushed commits
git config --global pull.rebase true
# diff
# diftool will use mergetool by default
git config --global merge.tool vimdiff
git config --global difftool.prompt false
git config --global diff.colormoved zebra
# editor
if command -v nvim >/dev/null 2>&1
then
git config --global core.editor nvim
git config --global mergetool.vimdiff.path nvim
elif command -v vim >/dev/null 2>&1
then
git config --global core.editor vim
git config --global mergetool.vimdiff.path vim
fi
# Aliases
git config --global alias.a add
git config --global alias.b '!git -P branch'
git config --global alias.bd '!git fetch --all --prune && git for-each-ref --format "%(refname) %(upstream:track)" refs/heads | perl -l0ne "print s#refs/heads/(.+) \[gone\]#\$1#r if /gone\]$/" | xargs -0 -n1 git branch -D'
git config --global alias.c 'commit -v'
git config --global alias.d 'diff -w'
git config --global alias.l 'log --graph --pretty="%C(auto)%h %C(242)%<(10,trunc)%ar %Cgreen%<(13,trunc)%an%C(auto)%d %s" -n11'
git config --global alias.ll 'log -pw'
# git config --global alias.o checkout
git config --global alias.f 'fetch --all --prune'
git config --global alias.g 'pull --all --prune'
git config --global alias.p push
git config --global alias.pu 'push -u origin HEAD'
git config --global alias.s 'status -sb'
git config --global alias.h help
git config --global alias.o browse
git config --global alias.st status
git config --global alias.cm commit
git config --global alias.co checkout
git config --global alias.bu '!fd --strip-cwd-prefix -FIH -td .git | parallel --no-notice --tag --tagstring {//} git -C {//}'
git config --global alias.bus '!find . -type d -name .git -printf "%P\n" | parallel --no-notice --tag --tagstring {//} git -C {//} -c color.status=always status -sb'
git config --global alias.br 'branch -avv'
git config --global alias.sha '!git -P show --oneline --quiet'
git config --global alias.last '!git -P log -1 --stat'
git config --global alias.sw '!git -P show -w'
git config --global alias.di diff
git config --global alias.dt difftool
git config --global alias.mt mergetool
git config --global blame.date format:'%d/%b/%Y %R'