# tig configuration file.
# vim: ft=config:noml:

set refresh-interval = 1
set refresh-mode = periodic

# dont display uncommitted changes.
set show-changes = no
set ignore-case = smart-case
# dont write ~/.tig_history.
set history-size = 0
# automatically pass line number to editor
set editor-line-number = yes

# same as the default - but use relative dates.
set main-view = date:relative author:full commit-title:yes,graph,refs
# set grep-view = file-name:no line-number:yes,interval=1 text
# 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,format="%Y-%m-%d" id:no file-name

# none
bind generic b none
bind generic c none
bind generic f none
bind generic r none
bind generic y none
# disable the default mapping for running git-gc
bind generic G none
bind main C none

# view manipulation
bind generic <Enter> enter
bind generic <Tab> view-next
bind generic <C-C> quit
bind generic <Down> next
bind generic <Up> previous
bind generic <C-N> next
bind generic <C-P> previous
bind generic <F5> refresh
# move to parent
bind generic , parent

# cursor navigation
bind generic - move-page-up
# mutt like bindings to move to first and last line.
bind generic = move-first-line
bind generic * move-last-line
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 <Home> move-first-line
bind generic <End> move-last-line

bind generic Y !sh -ec "echo %(commit) | yank"
# bind generic B !git rebase -i %(commit)^ --rebase-merges
# bind generic O !git checkout %(commit)
bind generic P !git format-patch -1 %(commit)
# bind generic R !git revert %(commit) --no-edit
# bind generic T !sh -ec "printf 'tag: '; git tag $(head -1) %(commit)"

# bind generic C !git commit
# bind generic D !>git difftool --tool=dirdiff --dir-dif --no-prompt  %(commit)^!
# bind generic V !git difftool --tool=code --no-prompt  %(commit)^!
# bind generic G move-last-line
# allow moving in the main menu while displaying a diff in the bottom of screen.
bind generic J next
bind generic K previous
bind generic L view-reflog
bind generic O maximize # Maximize the current view
bind generic Q quit # Close all views and quit
bind generic R refresh # Reload and refresh view
# compat binding to avoid going crazy!
# bind generic S view-status
# user-defined internal command that reloads ~/.tigrc
bind generic S :source ~/.config/tig/config

# misc
# open in editor
bind generic e edit
# open the prompt
# bind generic : prompt
bind generic z stop-loading
bind generic v show-version
bind generic <C-L> screen-redraw

# view switching
bind generic d view-diff
bind generic g view-grep
# bind generic gg move-first-line
# bind generic gj next
# bind generic gk previous
# bind generic gp parent
# bind generic gP back
# bind generic gn view-next
bind generic h view-help
bind generic j move-down
bind generic k move-up
bind generic l view-log
bind generic m view-main
bind generic p view-pager
# close the current view
bind generic q view-close
bind generic s view-status
bind generic t view-tree

# scrolling
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

# searching
bind generic / search
bind generic ? search-back
bind generic n find-next
bind generic N find-prev
# navigation keys used while searching
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

# option manipulation
# open the options menu
bind generic o options
# toggling settings
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 ??? :toggle show-changes # Toggle local changes display in the main view
bind generic W :toggle ignore-space # Toggle ignoring whitespace in diffs
# bind generic ??? :toggle ignore-case # Toggle ignoring case when searching
# bind generic ??? :toggle commit-order # Toggle commit ordering
bind generic X :toggle id # Toggle commit ID display
# toggle filtering by pathspecs in file-args
bind generic % :toggle file-filter
# toggle filtering by revisions in rev-args
bind generic ^ :toggle rev-filter

# jump to HEAD commit
bind main H :goto HEAD
bind main G :toggle commit-title-graph
bind main F :toggle commit-title-refs

# pager
bind pager @ :/^@@ # Jump to next (c)hunk

# diff
# close current view like in mutt.
bind diff i view-close
# jump to next (c)hunk
bind diff @ :/^@@
# decrease the diff context
bind diff [ :toggle diff-context -1
# increase the diff context
bind diff ] :toggle diff-context +1

# status
# stage/unstage changes in file
bind status u status-update
# revert changes in file
bind status ! status-revert
# open git-mergetool(1)
bind status M status-merge
# user-defined external command to amend the last commit
# bind status + !git commit --amend

# colors
# try to mimic gitks colors.
color date      default default
color delimiter default default           # ~ if text is too long

# main window.
color cursor         black   cyan         # currently selected line
color author         default default
color graph-commit   magenta default      # commit dots in graph
color main-head      green   default bold # HEAD
color main-ref       green   default      # branches
color main-remote    yellow  default      # remote branches
color main-tag       yellow  default bold # tags
color main-local-tag yellow  default bold # local tags (normal tags)

# information at the top of the commit diff.
color commit                default default
color "Author: "            default default
color "Commit: "            default default
color pp-merge              default default
color "Date: "              default default
color "AuthorDate: "        default default
color "CommitDate: "        default default
color pp-refs               default default

# special parts of the commit message.
color "    Acked-by"        default default
color "    Reviewed-by"     default default
color "    Signed-off-by"   default default
color "    Tested-by"       default default

# diff coloring.
color diff-header default default bold # diff --git a/.. b/..
color diff-index  default default bold # index abc..def
color diff-chunk  cyan    default      # @@ -.. +.. @@
