-
Notifications
You must be signed in to change notification settings - Fork 0
/
tigrc
79 lines (55 loc) · 2.33 KB
/
tigrc
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# Rebase
bind main r !git rebase --interactive --autosquash %(commit)
# Amend last commit
bind generic + !git commit --amend
# Switch to:
bind main b !git checkout -B "%(prompt Enter branch name: )" %(commit)
# Push
bind main P !git push
# Revert with 1 from main view
bind main 1 !git revert %(commit)
# Shift: Revert without committing
bind main ! !git revert --no-commit %(commit)
# Reset to highlighted commit, keep current working dir
bind main v !git reset --mixed %(commit)
# Shift: Reset to highlighted commit, hard
bind main V !git reset --hard %(commit)
# Create new branch here
bind main n !git checkout -b "%(prompt Enter branch name: )" %(commit)
# Merge branch
bind main M !git merge --no-ff %(branch)
# Customize the man view
set main-view = line-number:no,interval=5 id:no date:default author:abbreviated commit-title:yes,graph,refs,overflow=no
set vertical-split = no
# Checkout a file from tree view of a revision, commit, branch, by pressing t to go into tree view, then Ctrl-F to get the file back to that revision's version
bind generic <Ctrl-F> !?git checkout %(commit) %(file)
# TODO read more answered tig questions: https://stackoverflow.com/search?q=tig+answers%3A1
#########
# GENERIC
#########
# git - generic
bind generic g ?sh -c "git %(prompt git )"
######
# MAIN
######
# compare commit in log view with its parent per http://stackoverflow.com/questions/436362/shorthand-for-diff-of-git-commit-with-its-parent
bind main <F4> !git difftool -d %(commit)^!
# first key press creates compare-base, second key compares base to selected commit
bind main <F5> @git tig-compare-commits %(commit)
# create new branch
bind main <Ctrl-b> @git branch "%(prompt Enter new branch name: )" %(commit)
# copy commit hash
bind main C @sh -c "printf %(commit) | tr -d '\n' | pbcopy" # Mac
########
# STATUS
########
# compare selected file in status view. need to use revpase since %(file) is always relative to root but current directory might be nested in root already
bind status <F4> !sh -c "git difftool -y \"$(git rev-parse --show-toplevel)/%(file)\""
# add selected file to .gitignore
bind status <Ctrl-r> !sh -c "echo %(file) >> .gitignore && vi .gitignore"
# git --amend
bind status A !git commit --amend
# delete a
bind status D ?sh -c "rm \"$(git rev-parse --show-toplevel)/%(file)\""
# preview commit
bind status P !git commit-preview