# ━━━ Main ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ [[[
set main-options   = -n 1000 # User-defined options for `tig` (git-log)
set diff-context   = 3       # Number of lines to show around diff changes (diff)
# set diff-highlight = "delta"
# set diff-highlight = "/usr/bin/diff-so-fancy"    # String (or bool): Path to diff-highlight script,
# set diff-options  = -C             # User-defined options for `tig show` (git-diff)
# set blame-options    = -C -C -C    # User-defined options for `tig blame` (git-blame)
# set log-options    = --pretty=raw  # User-defined options for `tig log` (git-log)

# Display
set show-changes         = yes     # Show changes commits in the main view?
set show-untracked       = yes     # Show also untracked changes?
set show-notes           = yes     # When non-bool passed as `--show-notes=...` (diff)
set wrap-lines           = yes     # Wrap long lines in pager views?
set tab-size             = 2       # Number of spaces to use when expanding tabs
set line-graphics        = utf-8   # ascii default utf-8 auto
set truncation-delimiter = ~       # Character drawn for truncations, or "utf-8"

# Format reference names based on type.
#  - head           : The current HEAD.
#  - tag            : An annotated tag.
#  - local-tag      : A lightweight tag.
#  - remote         : A remote.
#  - tracked-remote : The remote tracked by current HEAD.
#  - replace        : A replaced reference.
#  - branch         : A branch.
#  - stash          : The stash.
#  - other          : Any other reference.
# If no format is defined for `local-tag` then the one for `tag` is used.
# Similarly, `remote` is used if no `tracked-remote` format exists.
# Prefix with `hide:` to not show that reference type, e.g. `hide:remote`.
# Expects a space-separated list of format strings.
set reference-format    = [branch] <tag> {remote} ~replace~

# Settings controlling how content is read from Git
set commit-order                = default # Enum: auto, default, topo, date, reverse (main)
set status-show-untracked-dirs  = no      # Show files in untracked directories? (status)
set status-show-untracked-files = yes     # Show untracked files?
set ignore-space                = no      # Enum: no, all, some, at-eol (diff)
set mailmap                     = yes     # Use .mailmap to show canonical name and email address?

# Scroll
set mouse              = yes  # Enable mouse support?
set mouse-scroll       = 3    # Number of lines to scroll via the mouse
set mouse-wheel-cursor = no   # Prefer moving the cursor to scrolling the view?
set pager-autoscroll   = no   # Scroll the pager view automatically while loading?
# View
set horizontal-scroll  = 33%  # Number of columns to scroll as % of width
set split-view-height  = 67%  # Height of the bottom view for horizontal splits
set vertical-split     = horizontal # (horizontal, vertical, auto); auto to switch to horiz split when width allows it
set split-view-width   = 50%  # Width of right-most view for vertical splits

# Misc
set start-on-head      = no   # Start with cursor on HEAD commit?
set refresh-mode       = auto # (manual, auto, after-command, periodic)
set refresh-interval   = 10   # Interval in seconds between refreshes
set ignore-case        = smart-case   # (no, yes, smart-case) ignore case when searching
set wrap-search        = yes  # Wrap around to top/bottom of view when searching?
set focus-child        = yes  # Move focus to child view when opened?
set send-child-enter   = yes  # Propagate "enter" keypresses to child views?
set editor-line-number = yes  # Automatically pass line number to editor? open file at line e.g. from a diff
set history-size       = 500  # Size of persistent history, 0 to disable
set pgrp               = no   # Make tig process-group leader?
# ]]]

# ━━━ Views ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ [[[
# Supported column types and their options:
#
#   author
#     - display (enum) [no|full|abbreviated|email|email-user] : Show author information?
#     - width (int)      : Fixed width when nonzero
#     - maxwidth (int)   : Autosize limit
#   commit-title
#     - display (bool)             : Show the commit title?
#     - graph (enum) [no|v2|v1]    : Show the commit graph? (main view only)
#     - refs (bool)                : Show branches, tags and remotes? (main view only)
#     - overflow (boolint)         : Highlight overflows? Defaults to 50 when enabled.
#   date
#     - display (enum) [no|default|relative|relative-compact|custom] : Show dates?
#     - local (bool)         : Show local dates?
#     - format (string)      : Custom strftime(3) format Note: %Z is formatted as %z
#     - width (int)          : Fixed width when nonzero
#   file-name
#     - display (enum) [no|always|auto] : Show file names?
#     - width (int)                     : Fixed width when nonzero
#     - maxwidth (int)                  : Autosize limit
#   file-size
#     - display (enum) [no|default|units] : Show file sizes?
#     - width (int)                       : Fixed width when nonzero
#   id
#     - display (bool) : Show commit/tree ID?
#     - width (int)    : Fixed width when nonzero
#   line-number
#     - display (bool) : Show line numbers?
#     - interval (int) : Interval between line numbers; defaults to 5
#     - width (int)    : Fixed width when nonzero
#   mode
#     - display (bool) : Show file modes?
#     - width (int)    : Fixed width when nonzero
#   ref
#     - display (bool) : Show ref names?
#     - width (int)    : Fixed width when nonzero
#     - maxwidth (int) : Autosize limit
#   status
#     - display (enum) [no|short|long] : Show status label?
#   text
#     - display (bool)                  : Show text?
#     - commit-title-overflow (boolint) : Highlight overflow in log and diff view?
#
set main-view   = line-number:no,interval=5 id:yes date:relative author:full commit-title:yes,graph:v2,refs,overflow=no
set blame-view  = date:default,format="%Y-%m-%d" author:full file-name:auto id:yes,color line-number:yes,interval=5 text
set grep-view   = file-name:no line-number:yes,interval=1 text
# line-number:no id:no
set refs-view   = date:default,format="%Y-%m-%d" author:full ref commit-title
set stash-view  = line-number:no,interval=5 id:no date:default,format="%Y-%m-%d" author:full commit-title
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" mode:yes id:no file-name
set reflog-view = line-number:no,interval=5 id:yes date:no,format="%Y-%m-%d" author:no commit-title:yes,refs,overflow=no

# Pager based views
set pager-view = line-number:no,interval=5 text
set stage-view = line-number:no,interval=5 text
set log-view   = line-number:no,interval=5 text
set blob-view  = line-number:no,interval=5 text
set diff-view  = line-number:no,interval=5 text:yes,commit-title-overflow=no
# ]]]

# ━━━ Bindings ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ [[[
# === Help === [[[
# These commands allow to run shell commands directly from within Tig.
# Unless otherwise specified, commands are run in the foreground with
# their console output shown (as if '!' was specified). When multiple
# command options are specified their behavior are combined, e.g. "?<git
# commit" will prompt the user whether to execute the command and will
# exit Tig after completion.
#
# ! Run the command in the foreground with output shown.
# @ Run the command in the background with no output.
# ? Prompt the user before executing the command.
# + Run the command synchronously, and echo the first line of output to the status bar.
# < Exit Tig after executing the command.
# > Re-open Tig instantly in the last displayed view after executing the command.
#
# %(prompt)        Prompt for the argument value. Optional custom prompt: `"%(prompt Enter branch:)`
# %(head)          current viewed 'head' ID. Defaults to HEAD
# %(commit)        current commit ID
# %(blob)          current blob ID
# %(branch)        current branch name
# %(remote)        current remote name. For remote branches %(branch) will contain branch name
# %(tag)           current tag name
# %(refname)       current reference name including the remote name for remote branches
# %(stash)         current stash name
# %(ref)           reference given to blame or HEAD if undefined

# %(directory)     current directory path in the tree view; empty for the root directory
# %(file)          currently selected file
# %(file_old)      old filename of the current selected file
# %(lineno)        current line number. Defaults to 0
# %(lineno_old)    current line number, before the diff was applied. Defaults to 0
# %(text)          text column of the current selected line

# %(repo:head)                name of the checked out branch, e.g. `master
# %(repo:head-id)             commit ID of the checked out branch
# %(repo:remote)              remote associated with the checked out branch, e.g. `origin/master`
# %(repo:cdup)                path to change directory to the repository root, e.g. `../
# %(repo:prefix)              path prefix of the current work directory, e.g `subdir/`
# %(repo:git-dir)             path to the Git directory, e.g. `/src/repo/.git`
# %(repo:worktree)            worktree path, if defined
# %(repo:is-inside-work-tree) whether Tig is running inside a work tree, either `true` or `false`

# %(revargs)       revision arguments passed on the command line
# %(fileargs)      file arguments passed on the command line
# %(cmdlineargs)   all other options passed on the command line
# %(diffargs)      diff options from `diff-options` or `TIG_DIFF_OPTS`
# %(blameargs)     options from 'blame-options' used by the blame view
# %(logargs)       options from 'log-options' used by the log view
# %(mainargs)      options from 'main-options' used by the main view

# :<number>              Jump to the specific line number, e.g. `:80`
# :<sha>                 Jump to a specific commit, e.g. `:2f12bcc`
# :<x>                   Execute the corresponding key binding, e.g. `:q`
# :!<command>            Execute a system command in a pager, e.g. `:!git log -p`
# :<action>              Execute a Tig command, e.g. `:edit`
# :goto <rev>            Jump to a specific revision, e.g. `:goto %(commit)^2`
# :goto <branch>         Jump to a specific branch
# :save-display <file>   Save current display to `<file>`
# :save-options <file>   Save current options to `<file>`
# :save-view <file>      Save view info to `<file>` (for testing purposes)
# :script <file>         Execute commands from `<file>`
# :exec <flags><args...> Execute command using `<args>` with external user-defined command option flags defined in `<flags>`
# :echo <args...>        Display text in the status bar
# ]]]

# === Builtin === [[[
# t = view-tree
# S = view-status

# # Save the current commit as a patch file when the user selects a commit
# # in the main view and presses 'S'.
# bind main S !git format-patch -1 %(commit)

# # Create and checkout a new branch; specify custom prompt
# bind main B ?git checkout -b "%(prompt Enter new branch name: )"

# # Show commit statistics for the author under the cursor
# bind main U +sh -c 'git --no-pager shortlog -s --author="$(git show -s --format=%aE %(commit))" </dev/tty'
# ]]]

# ━━━ Generic ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ [[[
# === View Switching === [[[
bind generic v  none
bind generic vm view-main
bind generic vd view-diff
bind generic vl view-log
bind generic vL view-reflog
bind generic ve view-reflog
bind generic vt view-tree
bind generic vx view-blob    # vf
bind generic vb view-blame
bind generic vr view-refs
bind generic vs view-status
bind generic vu view-stage   # vc
bind generic vy view-stash
bind generic vg view-grep
bind generic vp view-pager
bind generic vh view-help
bind generic g? view-help
# bind generic K  view-help
# ]]]

# === Option Toggling === [[[
# TODO: tree view toggle show id
# TODO: reflog-view-commit-title-graph

# author
# commit-order
# commit-title-graph
# commit-title-overflow
# commit-title-refs
# date
# file-filter
# file-name
# file-size
# id
# ignore-space
# line-graphics
# line-number
# rev-filter
# show-changes
# sort-field                    = tree refs
# sort-order                    = tree refs
# status
# status-show-untracked-dirs
# vertical-split

bind generic o  none
bind generic ow options                            # open the options menu
bind generic oo :toggle sort-order                 # toggle ascending/descending sort order
bind generic os :toggle sort-field                 # toggle field to sort by
bind generic on :toggle line-number                # toggle line numbers
bind generic od :toggle date                       # toggle date display
bind generic oa :toggle author                     # toggle author display
bind generic oG :toggle line-graphics              # toggle (line) graphics mode
bind generic of :toggle file-name                  # toggle file name display
bind generic oz :toggle file-size                  # toggle file size format
bind generic ol :toggle file-filter                # toggle filtering by pathspecs in file-args
bind generic op :toggle ignore-space               # toggle ignoring whitespace in diffs
bind generic oh :toggle show-changes               # toggle local changes display in the main view
bind generic oi :toggle id                         # toggle commit ID display
bind generic oe :toggle rev-filter                 # toggle filtering by revisions in rev-args
bind generic ou :toggle status-show-untracked-dirs # toggle display of file in untracked directories
bind generic ov :toggle vertical-split             # toggle vertical split
bind generic oj :toggle commit-order               # toggle commit ordering
bind generic ot :toggle commit-title-overflow      # toggle highlighting of commit title overflow

bind generic or :toggle commit-title-refs          # toggle reference display (tags/branches)
bind generic og :toggle commit-title-graph         # toggle revision graph visualization
bind generic oS :toggle status                     # toggle status display

bind generic oFn    :toggle file-name             # toggle file name display
bind generic oFz    :toggle file-size             # toggle file size format
bind generic oFl    :toggle file-filter           # toggle filtering by pathspecs in file-args
bind generic %      :toggle file-filter           # toggle filtering by pathspecs in file-args
bind generic ~      :toggle line-graphics         # toggle (line) graphics mode
bind generic <Hash> :toggle id                    # toggle commit ID
bind generic ^      :toggle rev-filter            # toggle filtering by revisions in rev-args
bind generic $      :toggle commit-title-overflow # toggle highlighting of commit title overflow
# bind generic .      :toggle line-number        # toggle line numbers

bind tree    *    :toggle file-name          # toggle showing filename in tree view

bind main    og   :toggle commit-title-graph # toggle revision graph visualization
bind main    or   :toggle commit-title-refs  # toggle reference display (tags/branches)
bind reflog  or   :toggle commit-title-refs  # toggle reference display (tags/branches)
bind status  ot   :toggle status             # toggle status display
bind status  oS   :toggle status             # toggle status display

bind generic ( :toggle split-view-height -5%   # decrease split height
bind generic ) :toggle split-view-height  5%   # increase split height

# bind generic I :toggle sort-order              # toggle ascending/descending sort order
# bind generic i :toggle sort-field              # toggle field to sort by
# bind generic D :toggle date                    # toggle date display
# bind generic A :toggle author                  # toggle author display
# bind generic F :toggle file-name               # toggle file name display
# bind generic W :toggle ignore-space            # toggle ignoring whitespace in diffs
# bind generic X :toggle id                      # toggle commit ID display
# ]]]

# === View Manipulation === [[[
bind generic g none
bind generic z none
bind generic R none

bind generic  q      view-close  # close the current view
bind generic  Q      quit        # close all views and quit
bind generic  <C-C>  quit        # close all views and quit
bind generic  <F5>   refresh     # reload and refresh view
bind generic  RR     refresh     # reload and refresh view
bind generic  O      maximize    # maximize the current view
bind generic  z/     maximize    # maximize the current view

bind generic <Enter>     enter       # enter and open selected entry
bind generic <Tab>       view-next   # move focus to the next view
bind generic <Lt>        back        # go back to the previous view state
bind generic <Down>      next        # move to next
bind generic <Up>        previous    # move to previous
bind generic <C-N>       next        # move to next
bind generic <C-P>       previous    # move to previous
bind generic <C-w><C-w>  view-next   # move focus to the next view

bind generic gj      next        # move to next
bind generic gk      previous    # move to previous
bind generic gn      view-next   # move focus to the next view
bind generic gp      parent      # move to parent
bind generic gP      back        # go back to the previous view state
bind generic g,      parent      # move to parent
bind generic g;      back        # go back to the previous view state
# bind generic H       back        # go back to the previous view state
# ]]]

# === Cursor / Scrolling === [[[
bind generic  j       move-down
bind generic  k       move-up
bind generic  h       scroll-left
bind generic  l       scroll-right
bind generic  gg      move-first-line
bind generic  G       move-last-line

bind generic  gJ      move-half-page-down
bind generic  gK      move-half-page-up
bind generic  J       scroll-half-page-down
bind generic  K       scroll-half-page-up
bind generic <PgDown> move-page-down
bind generic <PgUp>   move-page-up
bind generic <Space>  move-page-down
# bind generic  -       move-page-up
bind generic <Home>   move-first-line
bind generic <End>    move-last-line
# bind generic <C-F>    scroll-page-down
# bind generic <C-B>    scroll-page-up

bind generic  0       scroll-first-col
bind generic g0       scroll-first-col
bind generic |        scroll-first-col
bind generic <Left>   scroll-left
bind generic <Right>  scroll-right
bind generic <C-Y>    scroll-line-up
bind generic <C-E>    scroll-line-down
bind generic <Ins>    scroll-line-up
bind generic <Del>    scroll-line-down
bind generic <SBack>  scroll-page-up
bind generic <SFwd>   scroll-page-down
# bind generic  <>      scroll-half-page-up
# bind generic  <>      scroll-half-page-down
# ]]]

# === Search === [[[
bind generic  [    none
bind generic  ]    none
bind generic  /    search
bind generic  ?    search-back
bind generic  n    find-next
bind generic  N    find-prev
bind generic [q    find-prev
bind generic ]q    find-next

# 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 q      view-close
# ]]]

# === Help === [[[
bind help  z    none
bind help  zc   enter         # toggle open/close of binding folds
bind help  zo   enter         # toggle open/close of binding folds
bind help  z.   enter         # toggle open/close of binding folds
bind help  d    scroll-half-page-down
bind help  u    scroll-half-page-up
# ]]]

# === Misc === [[[
bind generic  :     prompt         # open the prompt
bind generic  <C-L> screen-redraw  # redraw the screen
bind generic  zR    screen-redraw  # redraw the screen
bind generic  zr    refresh        # reload and refresh view
bind generic  zS    stop-loading   # stop all loading views
bind generic  zV    show-version   # show Tig version

bind generic @      none
bind generic @k     :?^@@                    # jump to previous (c)hunk
bind generic @j     :/^@@                    # jump to next (c)hunk
bind generic @-     :toggle diff-context -1  # decrease the diff context
bind generic @+     :toggle diff-context +1  # increase the diff context

bind generic [c     :?^@@                    # jump to previous (c)hunk
bind generic ]c     :/^@@                    # jump to next (c)hunk
bind generic [m     move-prev-merge
bind generic ]m     move-next-merge
# ]]]

#  === External =========================================================== [[[
bind generic E   none
bind generic e   none
bind generic f   none

bind generic <C-o> edit
bind generic eo    edit
bind generic ed    edit
bind generic ev    edit                          # open in editor
bind generic eb    !>zsh -c "clear -x && bat -pf --paging=always -- \"%(file)\""
bind generic ee    !>zsh -c "rgu --height=100%"  # grep with fzf
bind generic ef    !>zsh -c "rgf --height=100%"  # find a file
bind generic fe    !>zsh -c "rgu --height=100%"  # grep with fzf
bind generic ff    !>zsh -c "rgf --height=100%"  # find a file
bind generic eg    !>zsh -c "FZFGIT_DEFAULT_OPTS='--height=100%' fedit"         # edit a file

bind generic fg    !>zsh -c 'git grep "%(prompt Grep: )"'  # grep with git using colored output

bind generic <C-g>   >zsh -c 'TIG_SCRIPT=<(print :bind generic q view-close) tig grep "%(prompt Searched pattern for grep view: )"'
bind generic et      !zsh -c '$TIG_SUITE_DIR/bin/tig-open-file $0' %(text)
bind pager   ee      !zsh -c '$TIG_SUITE_DIR/bin/tig-open-file $0' %(text)
bind pager   o       !zsh -c '$TIG_SUITE_DIR/bin/tig-open-file $0' %(text)
bind pager   E       !zsh -c '$TIG_SUITE_DIR/bin/tig-open-file $0' %(text)

bind generic L    none
bind generic Lg   !>zsh -c "lazygit"

# execute of past pager view commands
bind generic exe !>zsh  -c 'rm -f $TIG_SCRIPT;source $TIG_SUITE_GL&&feat/ti::run-task'

# === Config === [[[
bind generic Er   :source ~/.config/tig/config                   # reload config
bind generic ec   !>sh -c "$EDITOR $XDG_CONFIG_HOME/tig/config"  # edit config
bind generic Ec   !>sh -c "$EDITOR $XDG_CONFIG_HOME/tig/config"  # edit config
bind generic sc   :source ~/.config/tig/config                   # reload config

bind generic xec  !>sh -c "$EDITOR $XDG_CONFIG_HOME/tig/config"  # edit config
bind generic xre  !>sh -c "$EDITOR $XDG_CONFIG_HOME/tig/config"  # edit config    'e'dit
bind generic xrr  :source ~/.config/tig/config                   # reload config  'r'eload
bind generic xrc  :source ~/.config/tig/config                   # reload config  reload 'c'onfig
# ]]]

# === Tags === [[[
bind generic m    none

bind generic mt    :!make tags
bind generic mc    :!make ctags
bind generic mb    !zsh -c 'source $TIG_SUITE_GL&&ctags/ti::browse-tags'          # tag browsing in a pager
bind generic mec   !zsh -c 'source $TIG_SUITE_GL&&ctags/ti::create-tags c TAGS'   # create TAGS for C
bind generic mez   !zsh -c 'source $TIG_SUITE_GL&&ctags/ti::create-tags zsh TAGS' # create TAGS for zsh
bind generic mvc   !zsh -c 'source $TIG_SUITE_GL&&ctags/ti::create-tags c tags'   # create tags for C
bind generic mvz   !zsh -c 'source $TIG_SUITE_GL&&ctags/ti::create-tags zsh tags' # create tags for zsh

bind generic x!mt  :!make tags
bind generic x!mc  :!make ctags
bind generic x!b   !zsh -c 'source $TIG_SUITE_GL&&ctags/ti::browse-tags'          # tag browsing in a pager
bind generic x!tc  !zsh -c 'source $TIG_SUITE_GL&&ctags/ti::create-tags c TAGS'   # create TAGS for C
bind generic x!tz  !zsh -c 'source $TIG_SUITE_GL&&ctags/ti::create-tags zsh TAGS' # create TAGS for zsh
bind generic v!tc  !zsh -c 'source $TIG_SUITE_GL&&ctags/ti::create-tags c tags'   # create tags for C
bind generic v!tz  !zsh -c 'source $TIG_SUITE_GL&&ctags/ti::create-tags zsh tags' # create tags for zsh
# ]]]

# === Diff === [[[
bind generic d    none
bind generic dd  !>zsh -c "$EDITOR +'DiffviewOpen' +'bw 1'"                      # open diffview
bind generic do  !>zsh -c "$EDITOR +'DiffviewOpen' +'bw 1'"                      # open diffview
bind generic dp  !>zsh -c "$EDITOR +'DiffviewOpen %(commit)^!' +'bw 1'"
bind generic dl  !>zsh -c "$EDITOR +'DiffviewOpen %(commit)^! -- \"%(file)\"' +'bw 1'" # diffview with last
bind generic dh  !>zsh -c "$EDITOR +'DiffviewFileHistory' +'bw 1'"               # open diffview file hist
bind generic dc  !>zsh -c "$EDITOR +'DiffviewFileHistory \"%(file)\"' +'bw 1'"   # open diffview file hist
bind generic di  !>zsh -c "FORGIT_FZF_DEFAULT_OPTS='--height=100%' git forgit diff"
bind generic dtp !>git difftool -y %(commit)^!
bind generic dtf !>git difftool -y -- "%(file)"  # compare changed file in status view
bind generic de  !>zsh -c "clear -x && LESS=\"$LESS\" git diff \"%(file)\""  # same as above + delta

# Compare selected commit in log view (main view) with its parent
# bind generic xdp !git difftool -d %(commit)^!
# bind status xdf !>sh -c "git difftool -y \"$(git rev-parse --show-toplevel)/%(file)\""   # compare changed file in status view

# Compare changed file in status view
# bind status xdf !sh -c "git difftool -y \"$(git rev-parse --show-toplevel)/%(file)\""

# Vim [[[
bind generic xne  !>zsh -c "$EDITOR +'Gtabedit %(commit) -- \"%(file)\"' +'bw 1'"
bind generic xnd  !>zsh -c "$EDITOR +'DiffviewOpen' +'bw 1'"                      # open diffview
bind generic xno  !>zsh -c "$EDITOR +'DiffviewOpen' +'bw 1'"                      # open diffview
bind generic xnp  !>zsh -c "$EDITOR +'DiffviewOpen %(commit)^!' +'bw 1'"          # previous commit only
bind generic xnl  !>zsh -c "$EDITOR +'DiffviewOpen %(commit)^! -- \"%(file)\"' +'bw 1'" # previous commit only of file
bind generic xnh  !>zsh -c "$EDITOR +'DiffviewFileHistory' +'bw 1'"               # open diffview file hist
bind generic xnc  !>zsh -c "$EDITOR +'DiffviewFileHistory \"%(file)\"' +'bw 1'"   # open diffview file hist
bind generic xnf  !>zsh -c "$EDITOR +'lua require([[plugs.fugitive]]).index()'"   # open fugitive
bind generic xng  !>zsh -c "$EDITOR +'Flog' +'bw 1'"                              # open flog
bind generic xnn  !>zsh -c "$EDITOR +'Neogit' +'bw 1'"                            # open neogit

bind generic xdo  !>zsh -c "$EDITOR +'DiffviewOpen' +'bw 1'"        # open diffview
bind generic xdh  !>zsh -c "$EDITOR +'DiffviewFileHistory' +'bw 1'" # open diffview file hist
bind generic xdp  !>git difftool -y %(commit)^!                     # previous commit
bind generic xdf  !>git difftool -y -- "%(file)"                    # compare changed file in status view
bind generic xde  !>zsh -c "clear -x && LESS=\"$LESS\" git diff \"%(file)\"" # same as above + delta

## Compare selected commit in log view (main view) with its parent
# bind generic xdp  !>git difftool -d %(commit)^!
# ]]]
# ]]]

# === Commit === [[[
bind generic c    none
bind generic cc   !>git commit -S
bind generic cs   !>git commit -S
bind generic cl   !>git commit -S --all
bind generic ca   !>git commit -S --amend
bind generic ce   ?@git commit -S --amend --no-edit
bind generic cw   !>git commit -S --amend --only
bind generic cva  !>git commit -S --amend -v
bind generic cvc  !>git commit -S -v
bind generic cRa  !>git commit -S --reset-author --amend
bind generic cRe  ?@git commit -S --reset-author --amend --no-edit
bind generic cRw  !>git commit -S --reset-author --amend --only
bind generic cf   !>git commit -S --fixup=%(commit)
bind generic cq   ?@git commit -S --no-edit --squash=%(commit)
bind generic cA   !>git commit -S --edit --squash=%(commit)
bind generic cu   ?@git commit -S --reuse-message=HEAD
bind generic cU   ?@git commit -S --reuse-message=HEAD --amend
# bind generic +    !>git commit -S --amend

bind generic cF  !>zsh -c "FORGIT_FZF_DEFAULT_OPTS='--height=100%' git forgit fixup"
bind generic cp  !>zsh -c "FORGIT_FZF_DEFAULT_OPTS='--height=100%' git forgit cherry_pick"

bind generic crc   !git revert -S %(commit)
bind generic crn   !git revert --no-commit %(commit)
bind generic crC   !>zsh -c "FZFGIT_DEFAULT_OPTS='--height=100%' flog --revert" # revert to a commit
bind generic crU   !>zsh -c "FZFGIT_DEFAULT_OPTS='--height=100%' funtrack"      # untrack a file
bind generic cru   !>zsh -c "FZFGIT_DEFAULT_OPTS='--height=100%' freset"        # unstage a staged file

bind generic cm<Enter>  @git merge "%(prompt Merge command: )"
bind generic cmt        status-merge      # open git-mergetool(1) -- !git mergetool
# ]]]

# === Stash === [[[
bind generic cz<Enter>  +git stash "%(prompt Stash command: )"
bind generic czl        +git stash apply --index %(stash)
bind generic czL        +git stash apply %(stash)
bind generic czai       +git stash apply --index %(stash)
bind generic czaa       +git stash apply %(stash)
bind generic czap       !zsh -c 'source $TIG_SUITE_GL&&patch/ti::apply-stash ext %(commit) %(stash)'    # apply via `patch` tool
bind generic czRp       !zsh -c 'source $TIG_SUITE_GL&&patch/ti::apply-stash extrev %(commit) %(stash)' # apply via `patch` tool, REVERSED
bind generic czA        !zsh -c 'source $TIG_SUITE_GL&&patch/ti::apply-stash git %(commit) %(stash)'    # apply using `git stash apply`

bind generic czd       ?+git stash pop --index %(stash)
bind generic czP       ?+git stash pop %(stash)                                  # pop current stash
bind generic czP       ?!>zsh -c "FZFGIT_DEFAULT_OPTS='--height=100%' fstash -p" # show stashes and pop
bind generic czD       ?!>zsh -c "FZFGIT_DEFAULT_OPTS='--height=100%' fstash -d" # delete stash
bind generic cz!       +git stash clear                                          # remove all stashes

bind generic czw        +git stash push --keep-index                     # stash save keeping index
bind generic czz        +git stash push --keep-index --all               # stash save all keeping index
bind generic czu        +git stash push --keep-index --include-untracked # stash save + untracked keeping index
bind generic czh        +git stash push --keep-index --staged            # stash save + staged keeping index
bind generic czf        +git stash push --keep-index -- "%(file)"        # stash only highlighted file
bind generic czW        +git stash push       # stash everything
bind generic czcz       +git stash push       # stash everything
bind generic czZ        +git stash push --all # stash everything
bind generic czU        +git stash push --include-untracked
bind generic czH        +git stash push --staged
bind generic czF        +git stash push -p -- "%(file)" # stash interactively for 1 file
bind generic czif       +git stash push -p -- "%(file)" # stash interactively for 1 file
bind generic cziz       +git stash push -p              # stash interactively

bind generic czr        +zsh -c 'git stash drop %(stash); git stash store -m"%(prompt New stash name: )" %(commit)' # reset stash name

bind generic czS        !>zsh -c "FORGIT_FZF_DEFAULT_OPTS='--height=100%' git forgit stash_show"
bind generic czH        !>zsh -c "FORGIT_FZF_DEFAULT_OPTS='--height=100%' git forgit stash_push"

bind generic czM   +git stash "%(prompt Stash command: )"              # enter stash command
bind generic czmc  +git stash "%(prompt Stash command: )"              # enter stash command

bind generic czmz  +git stash --keep-index -m "%(prompt New stash: )"          # stash keeping index and prompting for message
bind generic czmi  +git stash push -p -m "%(prompt New stash: )"               # same interactively
bind generic czmu  +git stash push --include-untracked "%(prompt New stash: )" # stash all – also untracked files

bind generic czss  +git stash push -m "%(prompt New stash: )"                  # stash save
bind generic czsi  +git stash push --include-untracked "%(prompt New stash: )" # stash all – also untracked files

bind generic cz1j  !zsh -c 'source $TIG_SUITE_GL&&patch/ti::apply-stash extoth1 %(commit) %(stash) "%(file)"'    # diff way to gen patch
bind generic czj   !zsh -c 'source $TIG_SUITE_GL&&patch/ti::apply-stash extoth %(commit) %(stash) "%(file)"'     # same, but for whole saved diff (all files)
bind generic cz1rj !zsh -c 'source $TIG_SUITE_GL&&patch/ti::apply-stash extothrev1 %(commit) %(stash) "%(file)"' # reverse cz1j
bind generic czrj  !zsh -c 'source $TIG_SUITE_GL&&patch/ti::apply-stash extothrev %(commit) %(stash) "%(file)"'  # reverse czj
bind generic czR1j !zsh -c 'source $TIG_SUITE_GL&&patch/ti::apply-stash extothrev1 %(commit) %(stash) "%(file)"' # reverse cz1j
bind generic czRj  !zsh -c 'source $TIG_SUITE_GL&&patch/ti::apply-stash extothrev %(commit) %(stash) "%(file)"'  # reverse czj
# ]]]

# === Checkout === [[[
bind generic co<Enter>  @git checkout "%(prompt Checkout: )"
bind generic coo        +git checkout %(commit)
bind generic <C-j>      +git checkout %(branch)
bind generic cof        +git checkout %(file)
bind generic cob        +git switch %(branch)
bind generic co-        +git switch -
bind generic col        +git switch -
bind generic com        +git switch master
bind generic coM        +git switch main
bind generic coB        !>zsh -c "FORGIT_FZF_DEFAULT_OPTS='--height=100%' git forgit checkout_branch"
bind generic coO        !>zsh -c "FORGIT_FZF_DEFAULT_OPTS='--height=100%' git forgit checkout_commit"
bind generic coF        !>zsh -c "FORGIT_FZF_DEFAULT_OPTS='--height=100%' git forgit checkout_file"
bind generic coT        !>zsh -c "FORGIT_FZF_DEFAULT_OPTS='--height=100%' git forgit checkout_tag"
bind generic coS        !>zsh -c "FZFGIT_DEFAULT_OPTS='--height=100%' fcheckout -s"  # search all, not just modified

# bind generic cob   !>zsh -c "FZFGIT_DEFAULT_OPTS='--height=100%' fcheckout -b"  # checkout branch
# bind generic coo   !>zsh -c "FZFGIT_DEFAULT_OPTS='--height=100%' fcheckout -c"  # checkout commit
# bind generic cof   !>zsh -c "FZFGIT_DEFAULT_OPTS='--height=100%' fcheckout"     # checkout file
# ]]]

# === Branch === [[[
bind generic b      none
bind generic bd     ?!git branch -D %(branch)
bind generic <C-x>  ?!git branch -D %(branch)
bind generic bc     ?+git branch -c %(branch) "%(prompt Branch name: )"  # copy branch
bind generic bm     ?+git branch -m %(branch) "%(prompt Branch name: )"  # move branch
bind generic bD     ?!git push %(remote) --delete %(branch)
bind generic bl     !>zsh -c "clear -x && git branches | bat -pf --paging=always"
bind generic bL     !>zsh -c "clear -x && git remote-branches | bat -pf --paging=always"
# bind generic bM     +git checkout -b "%(prompt New branch: )" %(branch) # create new branch from existing
bind generic bn     @git branch "%(prompt Branch name: )"
bind generic bs     +git switch %(branch)
bind generic b-     +git switch -
bind generic bD     ?!>zsh -c "FORGIT_FZF_DEFAULT_OPTS='--height=100%' git forgit branch_delete"
# ]]]

# === Rebase === [[[
bind generic r          none
bind generic r<Enter>   !git rebase "%(prompt Rebase command: )"
bind generic rii        !git rebase --interactive
bind generic rir        !git rebase --interactive %(ref)
bind generic rih        !git rebase --interactive %(head)
bind generic ric        !git rebase --interactive %(commit)
bind generic rf        ?!git -c sequence.editor=true rebase --interactive --autosquash
bind generic rl        ?!git rebase --interactive --autosquash %(commit)^
bind generic ru         !git rebase --interactive @{upstream}
bind generic rp         !git rebase --interactive @{push}
bind generic rr         !git rebase --continue
bind generic rs        ?!git rebase --skip
bind generic ra        ?!git rebase --abort
bind generic re        ?!git rebase --edit-todo
bind generic rb        ?!>zsh -c "FORGIT_FZF_DEFAULT_OPTS='--height=100%' git forgit rebase"
bind generic rF         !>zsh -c "FORGIT_FZF_DEFAULT_OPTS='--height=100%' git forgit blame"
bind generic rE         !>zsh -c "FZFGIT_DEFAULT_OPTS='--height=100%' fedit -c"      # interactively edit rebase commit
bind generic rD         !>zsh -c "FZFGIT_DEFAULT_OPTS='--height=100%' fedit"         # edit a file
# ]]]

# === Add === [[[
bind generic a   none
bind generic aF  @git add -- "%(file)"                                  # add current file
bind generic an  @git add -- "%(file)"                                  # add current file
bind generic af  status-update                                          # stage/unstage changes in file
bind generic ar  status-revert                                          # revert changes in file
bind generic ap  @git add -p -- "%(file)"                               # partially add current file
bind generic al  @git add -N -- "%(file)"                               # record path will be added later
bind generic ai  !>zsh -c "FZFGIT_DEFAULT_OPTS='--height=100%' fadd -f" # add file
bind generic aD  !>zsh -c "FZFGIT_DEFAULT_OPTS='--height=100%' fadd -d" # add directory
bind generic ad  !>zsh -c "FORGIT_FZF_DEFAULT_OPTS='--height=100%' git forgit add"
bind generic as  !>zsh -c "FZFGIT_DEFAULT_OPTS='--height=100%' fstat"   # interactive status menu
bind generic aA  !>zsh -c "FZFGIT_DEFAULT_OPTS='--height=100%' fadd"
bind generic aU  ?@git rm --cached -- "%(file)"                         # untrack a file

bind generic uu status-update     # stage/unstage changes in file
bind generic ur status-revert     # revert changes in file
bind generic um status-merge      # open git-mergetool(1)
bind generic ul stage-update-line # stage/unstage current line
bind generic up stage-update-part # stage/unstage part of chunk
bind generic us stage-split-chunk # split current diff (c)hunk
# ]]]

# === Reset === [[[
bind generic Ruu   ?!git reset HEAD %(file)                              # unstage single file
bind generic RU    ?!git reset -q HEAD                                   # unstage all
bind generic Rus   !>zsh -c "FZFGIT_DEFAULT_OPTS='--height=100%' freset" # unstage a staged file
bind generic Rm    ?!git reset --mixed HEAD~1    # uncommit last
bind generic Rl    ?!git reset --soft HEAD^1     # undo last
bind generic Rf    ?!git reset --hard HEAD %(file)
bind generic Rg    ?!git reset --hard %(remote)/%(branch)
bind generic Rom   ?!git reset --hard %(remote)/master
bind generic RoM   ?!git reset --hard %(remote)/main
bind generic R1    ?!git reset --hard HEAD~1
bind generic R2    ?!git reset --hard HEAD~2
bind generic Rc    ?!git reset --soft %(commit)
bind generic RC    ?!git reset --hard %(commit)
bind generic Rhf   ?!git reset --hard HEAD %(file)
bind generic Rh1   ?!git reset --hard HEAD~1
bind generic Rh2   ?!git reset --hard HEAD~2
bind generic Rsc   ?!git reset --soft %(commit)
bind generic Rhc   ?!git reset --hard %(commit)
bind generic <C-r> ?!git reset --soft %(commit)
bind generic Rss   ?!>zsh -c "FZFGIT_DEFAULT_OPTS='--height=100%' freset -S" # use --soft flag
bind generic Rhs   ?!>zsh -c "FZFGIT_DEFAULT_OPTS='--height=100%' freset -H" # use --hard flag
bind generic Rd    ?!>zsh -c "FORGIT_FZF_DEFAULT_OPTS='--height=100%' git forgit reset_head"
bind generic Rt    ?!>zsh -c "FORGIT_FZF_DEFAULT_OPTS='--height=100%' git forgit revert_commit"
bind generic Rn     !>zsh -c "FZFGIT_DEFAULT_OPTS='--height=100%' funtrack" # untrack a file
bind generic RzU    !>zsh -c "FZFGIT_DEFAULT_OPTS='--height=100%' funtrack" # untrack a file
bind generic Rzu    !>zsh -c "FZFGIT_DEFAULT_OPTS='--height=100%' freset"   # unstage a staged file
# ]]]

# === Pull === [[[
bind generic P    none
bind generic Pa   !git pull
bind generic Pb   !git pull %(remote) %(branch)
bind generic Pm   !git pull origin master
bind generic Pll ?+git pull origin %(branch)
bind generic Plr ?+git pull origin %(branch) --rebase
bind generic Plm ?+git pull origin %(branch) --merge
bind generic Plo ?+git pull origin %(branch) -X ours --rebase
bind generic Plt ?+git pull origin %(branch) -X theirs --rebase
bind generic Pls ?!>zsh -c "git pull --depth 5 && git gc --prune=all" # (p)ull (s)hallow
# Prune
bind generic Ph ?!git gc --prune=all
bind generic Pp ?!>zsh -c "git pull --depth 5 && git gc --prune=all" # (p)ull (p)rune
bind generic Ps ?!>zsh -c "git pull --depth 5 && git gc --prune=all" # (p)ull (s)hallow
bind generic Pu ?!git fetch --unshallow                              # (p)ull (u)nshallow
# Fetch
bind generic fa  !git fetch --all
bind generic fp ?!git fetch --prune
bind generic fP ?!git fetch --prune --all
bind generic fu ?!git fetch --unshallow
# ]]]

# === Push === [[[
bind generic s     none
bind generic sa    ?+git push
bind generic sb    ?+git push %(remote) %(branch)
bind generic sB    ?+git push %(remote) --delete %(branch)
bind generic sr    ?+git push %(remote)
bind generic soM   ?+git push origin main
bind generic som   ?+git push origin master
bind generic sog   ?+git push origin
bind generic >     ?+git push %(remote) %(branch)
bind generic <C-b> ?!git push %(remote) --delete %(branch)

bind generic p    none
bind generic pa   ?+git push
bind generic pb   ?+git push %(remote) %(branch)
bind generic pB   ?+git push %(remote) --delete %(branch)
bind generic pr   ?+git push %(remote)
bind generic poM  ?+git push origin main
bind generic pom  ?+git push origin master
bind generic pog  ?+git push origin
# ]]]

# === Log === [[[
bind generic gl  !>git log %(file)
bind generic Lf  !>git log %(file)
bind generic Ll  !>zsh -c "clear -x && LESS=\"$LESS\" git log -p --color=always"  # full log
bind generic Lw  !>zsh -c "clear -x && LESS=\"$LESS\" git log --diff-filter=A \"%(file)\""  # when added
bind generic Lo  !>zsh -c "FORGIT_FZF_DEFAULT_OPTS='--height=100%' git forgit log"
# ]]]

# === Browse === [[[
bind generic Bo @git brws           # open on Github
bind generic Bf @git brws %(file)   # open file on Github
bind generic Bc @git brws %(commit) # open commit on Github
bind generic Bt @git brws %(tag)    # open tag on Github

# bind generic Bc @sh -c "handlr open 'https://'$(git remote -v | grep -Eo 'github.com[:/][^.]+' | head -1 | sed 's/ (fetch)//g' | tr : /)'/commit/%(commit)'"
# bind generic Bh @git open
# ]]]

# === Submodule === [[[
bind generic mp  @git submodule foreach git pull  # update each submodule
bind generic mo  @git submodule foreach git checkout master  # checkout each submodule
bind generic mu  @git submodule update --init --recursive # update submodule
bind generic mU  @git submodule update --init --remote # upgrade submodule
# ]]]

# === Miscellaneous === [[[
bind generic T   !>git notes edit %(commit)  # add notes to a commit
bind generic gc  !>zsh -c "FORGIT_FZF_DEFAULT_OPTS='--height=100%' git forgit clean"
bind generic gi  !>zsh -c "FORGIT_FZF_DEFAULT_OPTS='--height=100%' git forgit ignore"
bind generic gL  !>zsh -c "FORGIT_FZF_DEFAULT_OPTS='--height=100%' git forgit blame"
bind generic gb  !>zsh -c "FZFGIT_DEFAULT_OPTS='--height=100%' fbackup"       # backup tracked files
bind generic gB  !>zsh -c "FZFGIT_DEFAULT_OPTS='--height=100%' fbackup -s"    # backup selected files
bind generic slt !>zsh -c "clear -x && git shortlog --pretty=ref --numbered --email --tags | bat -pf --paging=always"
bind generic sln !>zsh -c "clear -x && git shortlog --pretty=ref --numbered --email | bat -pf --paging=always"

# List tracked files
bind generic gtt !>zsh -c "clear -x && git ls-ttracked | sponge | bat -pf --paging=always"
# List untracked files
bind generic gtu !>zsh -c "clear -x && git ls-tuntracked | sponge | bat -pf --paging=always"
# ]]]

# === Forgit === [[[
bind generic ,     none
bind generic ,aa   !>zsh -c "FORGIT_FZF_DEFAULT_OPTS='--height=100%' git forgit add"
bind generic ,af   !>zsh -c "FZFGIT_DEFAULT_OPTS='--height=100%' fadd -f"       # add file
bind generic ,ad   !>zsh -c "FZFGIT_DEFAULT_OPTS='--height=100%' fadd -d"       # add directory
bind generic ,bl   !>zsh -c "FORGIT_FZF_DEFAULT_OPTS='--height=100%' git forgit blame"
bind generic ,bd  ?!>zsh -c "FORGIT_FZF_DEFAULT_OPTS='--height=100%' git forgit branch_delete"
bind generic ,fu   !>zsh -c "FORGIT_FZF_DEFAULT_OPTS='--height=100%' git forgit fixup"
bind generic ,rh  ?!>zsh -c "FORGIT_FZF_DEFAULT_OPTS='--height=100%' git forgit reset_head"
bind generic ,rb  ?!>zsh -c "FORGIT_FZF_DEFAULT_OPTS='--height=100%' git forgit rebase"
bind generic ,rc  ?!>zsh -c "FORGIT_FZF_DEFAULT_OPTS='--height=100%' git forgit revert_commit"
bind generic ,rC   !>zsh -c "FZFGIT_DEFAULT_OPTS='--height=100%' flog --reset"  # reset HEAD to a commit
bind generic ,rS  ?!>zsh -c "FZFGIT_DEFAULT_OPTS='--height=100%' freset -S"     # use --soft flag
bind generic ,rH  ?!>zsh -c "FZFGIT_DEFAULT_OPTS='--height=100%' freset -H"     # use --hard flag
bind generic ,ss   !>zsh -c "FORGIT_FZF_DEFAULT_OPTS='--height=100%' git forgit stash_show"
bind generic ,sp   !>zsh -c "FORGIT_FZF_DEFAULT_OPTS='--height=100%' git forgit stash_push"
bind generic ,sP  ?!>zsh -c "FZFGIT_DEFAULT_OPTS='--height=100%' fstash -p"     # show stashes and pop
bind generic ,sd  ?!>zsh -c "FZFGIT_DEFAULT_OPTS='--height=100%' fstash -d"     # delete stash

bind generic ,cl  !>zsh -c "FORGIT_FZF_DEFAULT_OPTS='--height=100%' git forgit clean"
bind generic ,cp  !>zsh -c "FORGIT_FZF_DEFAULT_OPTS='--height=100%' git forgit cherry_pick"
bind generic ,cb  !>zsh -c "FORGIT_FZF_DEFAULT_OPTS='--height=100%' git forgit checkout_branch"
bind generic ,co  !>zsh -c "FORGIT_FZF_DEFAULT_OPTS='--height=100%' git forgit checkout_commit"
bind generic ,cf  !>zsh -c "FORGIT_FZF_DEFAULT_OPTS='--height=100%' git forgit checkout_file"
bind generic ,ct  !>zsh -c "FORGIT_FZF_DEFAULT_OPTS='--height=100%' git forgit checkout_tag"
bind generic ,ig  !>zsh -c "FORGIT_FZF_DEFAULT_OPTS='--height=100%' git forgit ignore"
bind generic ,di  !>zsh -c "FORGIT_FZF_DEFAULT_OPTS='--height=100%' git forgit diff"
bind generic ,lo  !>zsh -c "FORGIT_FZF_DEFAULT_OPTS='--height=100%' git forgit log"

bind generic ,lr  !>zsh -c "FZFGIT_DEFAULT_OPTS='--height=100%' flog --revert" # revert to a commit
bind generic ,lR  !>zsh -c "FZFGIT_DEFAULT_OPTS='--height=100%' flog --reset"  # reset HEAD to a commit

bind generic ,ut  !>zsh -c "FZFGIT_DEFAULT_OPTS='--height=100%' funtrack"      # untrack a file
bind generic ,us  !>zsh -c "FZFGIT_DEFAULT_OPTS='--height=100%' freset"        # unstage a staged file
bind generic ,rs  !>zsh -c "FZFGIT_DEFAULT_OPTS='--height=100%' freset"        # unstage a staged file

bind generic ,ka  !>zsh -c "FZFGIT_DEFAULT_OPTS='--height=100%' fbackup"       # backup tracked files
bind generic ,ks  !>zsh -c "FZFGIT_DEFAULT_OPTS='--height=100%' fbackup -s"    # backup selected files

#  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

bind generic ;     none
bind generic ;t    !>zsh -c "FZFGIT_DEFAULT_OPTS='--height=100%' fstat"         # interactive status menu
bind generic ;aa   !>zsh -c "FZFGIT_DEFAULT_OPTS='--height=100%' fadd"
bind generic ;af   !>zsh -c "FZFGIT_DEFAULT_OPTS='--height=100%' fadd -f"       # add file
bind generic ;ad   !>zsh -c "FZFGIT_DEFAULT_OPTS='--height=100%' fadd -d"       # add directory
bind generic ;ka   !>zsh -c "FZFGIT_DEFAULT_OPTS='--height=100%' fbackup"       # backup tracked files
bind generic ;ks   !>zsh -c "FZFGIT_DEFAULT_OPTS='--height=100%' fbackup -s"    # backup selected files

bind generic ;cb   !>zsh -c "FZFGIT_DEFAULT_OPTS='--height=100%' fcheckout -b"  # checkout branch
bind generic ;co   !>zsh -c "FZFGIT_DEFAULT_OPTS='--height=100%' fcheckout -c"  # checkout commit
bind generic ;cF   !>zsh -c "FZFGIT_DEFAULT_OPTS='--height=100%' fcheckout -s"  # search all, not just modified
bind generic ;cf   !>zsh -c "FZFGIT_DEFAULT_OPTS='--height=100%' fcheckout"     # checkout file
bind generic ;e    !>zsh -c "FZFGIT_DEFAULT_OPTS='--height=100%' fedit"         # edit a file
bind generic ;re   !>zsh -c "FZFGIT_DEFAULT_OPTS='--height=100%' fedit -c"      # interactively edit rebase commit

bind generic ;ut   !>zsh -c "FZFGIT_DEFAULT_OPTS='--height=100%' funtrack"      # untrack a file
bind generic ;us   !>zsh -c "FZFGIT_DEFAULT_OPTS='--height=100%' freset"        # unstage a staged file
bind generic ;rs   !>zsh -c "FZFGIT_DEFAULT_OPTS='--height=100%' freset"        # unstage a staged file
bind generic ;rc   !>zsh -c "FZFGIT_DEFAULT_OPTS='--height=100%' freset -c"     # reset HEAD to a commit
bind generic ;rS  !?>zsh -c "FZFGIT_DEFAULT_OPTS='--height=100%' freset -S"     # use --soft flag
bind generic ;rH  !?>zsh -c "FZFGIT_DEFAULT_OPTS='--height=100%' freset -H"     # use --hard flag

bind generic ;lo   !>zsh -c "FZFGIT_DEFAULT_OPTS='--height=100%' flog"          # view log
bind generic ;lr   !>zsh -c "FZFGIT_DEFAULT_OPTS='--height=100%' flog --revert" # revert to a commit
bind generic ;lR   !>zsh -c "FZFGIT_DEFAULT_OPTS='--height=100%' flog --reset"  # reset HEAD to a commit

bind generic ;ss   !>zsh -c "FZFGIT_DEFAULT_OPTS='--height=100%' fstash"        # show stashes and apply
bind generic ;sP  !?>zsh -c "FZFGIT_DEFAULT_OPTS='--height=100%' fstash -p"     # show stashes and pop
bind generic ;sd  !?>zsh -c "FZFGIT_DEFAULT_OPTS='--height=100%' fstash -d"     # delete stash

bind generic ;gg   !>zsh -c "FZFGIT_DEFAULT_OPTS='--height=100%' fzgrep"        # git grep repo
bind generic ;gr   !>zsh -c "rgu --height=100%"                                 # regular grep
bind generic ;gf   !>zsh -c "rgf --height=100%"                                 # find a file
# ]]]

# === Info === [[[
bind generic y none
# bind generic yy !@csh -c "echo -n %(commit) | xsel -ib"
# bind generic yb !@csh -c "echo -n %(branch) | xsel -ib"
# bind generic yr !@csh -c "echo -n %(remote) | xsel -ib"

bind generic yy +csh -c "echo -n %(commit) | xsel -ib --trim && printf 'Copied: commit [%(commit)]' || printf 'Error copying commit ID: %(commit)'"
bind generic yc +csh -c "echo -n %(commit) | xsel -ib --trim && printf 'Copied: commit [%(commit)]' || printf 'Error copying commit ID: %(commit)'"
bind generic yb +csh -c "echo -n %(branch) | xsel -ib --trim && printf 'Copied: branch [%(branch)]' || printf 'Error copying branch: %(branch)'"
bind generic yr +csh -c "echo -n %(remote) | xsel -ib --trim && printf 'Copied: remote [%(remote)]' || printf 'Error copying remote: %(remote)'"
bind generic yR +csh -c "echo -n %(ref)    | xsel -ib --trim && printf 'Copied: ref [%(ref)]'       || printf 'Error copying ref: %(ref)'"
bind generic ys +csh -c "echo -n %(stash)  | xsel -ib --trim && printf 'Copied: stash [%(stash)]'   || printf 'Error copying stash: %(stash)'"
bind generic yh +csh -c "echo -n %(head)   | xsel -ib --trim && printf 'Copied: head [%(head)]'     || printf 'Error copying head: %(head)'"
bind generic yB +csh -c "echo -n %(blob)   | xsel -ib --trim && printf 'Copied: blob [%(blob)]'     || printf 'Error copying blob: %(blob)'"
bind generic yf +csh -c "xsel -ib --trim <\"%(file)\" && printf 'Copied: file contents [%(file)]'   || printf 'Error copying file contents: %(file)'"
bind generic yu +zsh -c '\
    local url=\"$(git remote get-url origin)\" && \
    printf $url | xsel -ib --trim && \
    (printf "Copied: URL [$url]" || printf "Error copying URL: $url")'

bind generic s,f +csh -c "printf '[FILE:%(file)]'"
bind generic s,d +csh -c "printf '[DIRECTORY:%(directory)]'"
bind generic s,F +csh -c "printf '[OLD_FILE:%(file_old)]'"
bind generic s,l +csh -c "printf '[LINENO:%(lineno)] [COLUMN:%(text)]'"
bind generic s,a +csh -c "printf '[BRANCH:%(branch)] [COMMIT:%.8s] [REMOTE:%(remote)] [HEAD:%(head)] [TAG:%(tag)] [REFNAME:%(refname)]' %(commit)"
bind generic s,h +csh -c "printf '[HEAD:%(head)] [ID:%(repo:head-id)]'"
bind generic s,c +csh -c "printf '[COMMIT:%(commit)]'"
bind generic s,B +csh -c "printf '[BLOB:%(blob)]'"
bind generic s,b +csh -c "printf '[BRANCH:%(branch)]'"
bind generic s,r +csh -c "printf '[REMOTE:%(remote)]'"
bind generic s,t +csh -c "printf '[TAG:%(tag)]'"
bind generic s,n +csh -c "printf '[REFNAME:%(refname)]'"
bind generic s,s +csh -c "printf '[STASH:%(stash)]'"
bind generic s,R +csh -c "printf '[REF:%(ref)]'"
bind generic s,o +csh -c "printf 'Repo: [Head:%(repo:head)] [ID:%(repo:head-id)] [Remote:%(repo:remote)]'"
bind generic s,i +csh -c "printf 'Info: [GIT_DIR:%(repo:git-dir)] [GIT_TREE:%(repo:worktree)] [Prefix:%(repo:prefix)]'"
bind generic s,A +csh -c "printf 'Args: [Cli:%(cmdlineargs)] [Main:%(mainargs)] [Rev:%(revargs)] [File:%(fileargs)] [Diff:%(diffargs)] [Blame:%(blameargs)]'"
bind generic s,r +zsh -c 'printf "Repo: [URL:$(git remote get-url origin)]"'
# ]]]

# === Features === [[[

###
### Patch support
###

# Create a patch file with git format-patch
bind generic xfp !zsh -c 'source $TIG_SUITE_GL||exit 1;qe=$PDIR/patches;mkdir -p $qe;q="%(prompt Patch file name without .patch extension: ).patch";noglob command git format-patch --ignore-space-at-eol -N -k --progress --stdout %(commit)..%(commit)>!$qe/$q&&[[ -f $qe/$q ]]&&tigmsg_ -h "%B{33}PATCH CREATED at: {41}%U${qe/$PDIR\\/}/$q"||tigmsg_ "%B{208}PROBLEM CREATING THE PATCH!"'

# Apply a patch with (p)git or (P)patch command
bind generic xap !zsh -c 'source $TIG_SUITE_GL||exit 1; \
    tigmsg_ -h  "%B{205}––– Dry-run with {41}git apply{205}: ———%f%b"; \
    git apply --stat --summary --ignore-space-change --whitespace=fix --recount "%(file)"; \
    tigmsg_ -h  "%B{205}––– Now applying patch with {41}git apply{205}: ———%f%b"; \
    noglob command git apply -3 --ignore-space-change --recount "%(file)" && \
        tigmsg_ -h "%B{33}Patch applied cleanly" || tigmsg_ -h "%B{205}Errors when applying patch"'

bind generic xaP !zsh -c 'source $TIG_SUITE_GL||exit 1;tigmsg_ -h  %B{205}––– Dry-run with {41}git apply{205}: ———%f%b;git apply --stat --summary --ignore-space-change --whitespace=fix --recount "%(file)";tigmsg_ -h %B{205}––– Now applying with {41}patch{205} command: –––%f%b; noglob command patch -p1 -F7000 --ignore-whitespace -i "%(file)"&&tigmsg_ -h %B{33}Patch applied cleanly||tigmsg_ -h %B{205}Errors when applying patch'

bind generic equ !zsh  -c 'source $TIG_SUITE_GL&&feat/ti::edit-external queue $PID'     # edit queue file
bind generic efe !zsh  -c 'source $TIG_SUITE_GL&&feat/ti::edit-external features $PID'  # edit feature file
bind generic esq !zsh  -c 'source $TIG_SUITE_GL&&feat/ti::show-files-general queue'     # view of files in queue
# view of files in commit
bind generic esc !zsh  -c 'source $TIG_SUITE_GL&&feat/ti::show-files-general commit  "${${${${:-%(commit)}//$~TIZERO_PAT/}:-%(blob)}//$~TIZERO_PAT/}"'

# Feature creation [[[
# `n`…ew`c`…commit → new feature from highlighted commit
# bind generic enc !zsh  -c 'source $TIG_SUITE_GL&&feat/ti::new-feature "%(prompt What name-ID to the new feature to give? )" "${${${${:-%(commit)}//$~TIZERO_PAT/}:-%(blob)}//$~TIZERO_PAT/}" "commit"'
# `n`…ew`q`…ueue → new feature from the queue/accumulator
# bind generic enq !zsh  -c 'source $TIG_SUITE_GL&&feat/ti::new-feature "%(prompt What name-ID to the new feature to give? )" "${${${${:-%(commit)}//$~TIZERO_PAT/}:-%(blob)}//$~TIZERO_PAT/}" "queue"'
# ]]]

# ]]]

# === Accumulator === [[[
bind generic esvt !zsh -c 'source $TIG_SUITE_GL&&feat/ti::copy-files tree'  # save current tree (of HEAD)
# savee from highlighted commit tree
bind generic esvT !zsh -c 'source $TIG_SUITE_GL&&feat/ti::copy-files tree-of-commit "${${${${${:-%(commit)}//$~TIZERO_PAT/}:-%(blob)}//$~TIZERO_PAT/}:-}"'
# 'q'…ueue'e'…mpty → prune queue/accumulator
bind generic eqe !zsh -c 'source $TIG_SUITE_GL&&print -n>!$TIPID_QUEUE&&tigmsg_ %B{208}Notice: {33}Emptied accu/queue-file $MSG3||tigmsg_ %B{205}Error: {137}Could not empty accu/queue-file'

bind generic esvf !zsh -c 'source $TIG_SUITE_GL&&feat/ti::save-file-to-PID-queue "%(file)"' # save current file
bind generic esvF !zsh -c 'source $TIG_SUITE_GL&&feat/ti::copy-files feature'  # save files from feature into queue
# 's'…a'v'…e files from picked commit into queue/accumulator
bind generic esvc !zsh -c 'source $TIG_SUITE_GL&&feat/ti::copy-files commit "${${${${${:-%(commit)}//$~TIZERO_PAT/}:-%(blob)}//$~TIZERO_PAT/}:-}"'
# ]]]
# ]]]
# ]]]

# ━━━ View Specific ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ [[[

# === Status === [[[
bind status u  none
bind status D  none
bind status DD ?@rip -- "%(file)"  # delete a file

bind status R  ?!git reset HEAD -- "%(file)"
bind status A   !git commit -S --amend
bind status N   @git add -N -- "%(file)"      # record path will be added later
bind status U  ?@git rm --cached -- "%(file)"
bind status +  status-update   # stage/unstage changes in file
bind status -  status-revert   # revert changes in file
# bind status aF  ?@git add %(file)                                      # add current file
# bind status ap  ?@git add -p %(file)                                   # partially add current file

# bind generic crU   !>zsh -c "FZFGIT_DEFAULT_OPTS='--height=100%' funtrack"      # untrack a file
# bind generic cru   !>zsh -c "FZFGIT_DEFAULT_OPTS='--height=100%' freset"        # unstage a staged file

bind status pr !git push %(remote)
bind status xpga !git push
bind status xpom !git push origin master
bind status xpog !git push origin

bind status xss  +git stash push -m "%(prompt New stash: )"                  # stash save
bind status xsis +git stash push --include-untracked "%(prompt New stash: )" # stash all – also untracked files
# ]]]

# === Diff === [[[
bind diff @   none
bind diff [   none
bind diff ]   none

bind diff <Down> move-down
bind diff <Up>   move-up

bind diff _      :toggle diff-context -1  # decrease the diff context by 1
bind diff -      :toggle diff-context -1  # decrease the diff context by 1
bind diff +      :toggle diff-context +1  # increase the diff context by 1
bind diff g-     :toggle diff-context -5  # decrease the diff context by 5
bind diff g+     :toggle diff-context +5  # increase the diff context by 5

# Edit all files of commit
bind diff A @git add %(file)              # add current file
bind diff C !git commit -av               # add and commit
# bind diff p !git add -p %(file)           # partially add current file
bind diff F !sh -c "git show %(commit) --pretty=format: --name-only | xargs | xsel -ib --trim" # copy file change names
bind diff E !>zsh -c "$EDITOR +'Gtabedit %(commit) -- \"%(file)\"' +'bw 1'"
bind diff V !>zsh -c "$EDITOR -- $(git show %(commit) --pretty=format: --name-only)"

bind diff pr   !git push %(remote)
bind diff xpga !git push
bind diff xpom !git push origin master
bind diff xpog !git push origin
# ]]]

# === Stage === [[[
bind stage @  none
bind stage [  none
bind stage ]  none

# bind stage   u  none

bind stage  1 stage-update-line  # stage a single line
bind stage  2 stage-update-part  # stage/unstage part of chunk
bind stage  ! status-revert      # revert current diff (c)hunk

bind stage C    !git commit # Commit staging changes
bind stage pr   !git push %(remote)
bind stage xpga !git push
bind stage xpom !git push origin master
bind stage xpog !git push origin
# ]]]

# === Main === [[[
bind main  G   move-last-line
bind main  H   :goto HEAD    # jump to HEAD commit

bind main g    none
bind main gf   !git fetch
bind main gr  ?!git revert %(commit)

bind main ! ?!git revert %(commit)
bind main A ?@git commit --amend --reuse-message=HEAD
bind main C ?!git checkout %(commit)
bind main S ?!git reset --hard %(commit)
bind main R ?!git rebase -i --autosquash %(commit)^
bind main F ?@git commit --fixup %(commit)
bind main Z !git cherry-pick %(commit)
bind main E !>zsh -c "$EDITOR +'Gtabedit %(commit) -- \"%(file)\"' +'bw 1'"
bind main V !>zsh -c "$EDITOR +'DiffviewOpen %(commit)^!' +'bw 1'"
bind main Y +csh -c "echo -n %(commit) | xsel -ib --trim && printf 'Copied: commit [%(commit)]' || printf 'Error copying commit ID: %(commit)'"

bind main pr   !git push %(remote)
bind main xpga !git push
bind main xpom !git push origin master
bind main xpog !git push origin

# Compare two selected commits
bind main xd2 !sh -c "echo Checking branch existence; \
    if [ \"$(git branch --list temp-compare-base)\" != \"\" ]; then\
        echo Branch exists, comparing with %(commit); \
        git difftool -d temp-compare-base..%(commit); \
        git branch --delete temp-compare-base; \
    else \
        echo Creating initial branch at %(commit); \
        git branch temp-compare-base %(commit); \
    fi;"
# ]]]

# === Tree === [[[
bind tree D  none
bind tree E  edit
bind tree V  !>zsh -c "clear -x && bat -pf --paging=always -- \"%(file)\""
bind tree DD ?@rip -- "%(file)"  # delete a file
# ]]]

# === Branch === [[[
bind branch D   none
bind branch N   +git branch "%(prompt Branch name: )"
bind branch C   +git checkout %(branch)
bind branch R  ?@git rebase
bind branch DD ?@git branch -D %(branch)
bind branch !  ?@git branch -D %(branch)
# ]]]

# === Refs === [[[
bind refs D   none
bind refs C   +git checkout %(ref)
bind refs DD ?@git branch -D %(branch)
bind refs !  ?@git branch -D %(branch)
bind refs gc  +git checkout %(ref)
bind refs g-  +git switch -
# bind refs bs  +git switch %(branch)
# bind refs bc  ?!git branch -c %(branch) "%(prompt Branch name: )"  # copy branch
# bind refs bm  ?!git branch -m %(branch) "%(prompt Branch name: )"  # move branch

bind refs <C-h> ?@git reset --hard %(remote)/%(branch)
bind refs xnb   !@git checkout -b "%(prompt New branch: )" %(branch) # create a new branch from the selected one
# ]]]

# === Stash === [[[
bind stash DD ?!git stash drop %(stash)  # drop the selected stash
bind stash A  ?!git stash apply %(stash) # apply the selected stash
# ]]]

# === Pager === [[[
bind pager @  none
# ]]]

# === Grep === [[[
bind grep ee edit   # open in editor
# ]]]

# === Log === [[[
# bind log V edit
# bind log V !>sh -c "$EDITOR \"$(git rev-parse --show-toplevel)/%(file)\""
# ]]]
# ]]]

# ━━━ Colors ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ [[[
color cursor      color42 color52 bold
color status      color88 default        # messages at the bottom
color date        color21 default

# color title-focus color42 color78 bold
# color title-blur  color43 color78 bold
color title-focus color42 color39 bold
color title-blur  color54 color39 bold

color author         red     default bold
color main-head      magenta default
color main-tag       magenta default
color stat-staged    green   default
color stat-unstaged  red     default
color stat-untracked yellow  default
color tree.header    color52 default
color tree.directory cyan    default

color "commit "      green   default bold
color "parent "      blue    default
color "tree "        blue    default
color "author "      color21 default
color "committer "   color19 default
color "Author: "     color21 default
color "Commit: "     color19 default
color "Tagger: "     color13 default
color "Merge: "      color68 default bold
color "Date: "       yellow  default
color "AuthorDate: " color14 default
color "CommitDate: " color14 default

color "---"              color81 default bold
color "--- "             color80 default bold
color "diff --"          color48 default bold
# color "+++"              color2  default bold
color "+++ "             color2  default bold
color "@@"               color15 default
color "+"                green   default
color " +"               green   default
color "-"                color12 default bold
color " -"               color12 default bold
color diff-stat          color18 default
color diff-add-highlight color10 default bold
color diff-del-highlight color12 default bold

# color "/^[-–—]+$/" magenta default normal
# color "/^[^·–—0-9]+/" blue default bold
# color "/^[0-9]+\./" color135 default bold

# color " | "              color45 default bold

# color "(+)"              green   default
# color "(-)"              color12 default bold
# color "insertions(+)"    color2  default bold
# color "deletions(+)"     color80 default bold

color " 1 file changed"   color51 default bold
color " 2 files changed"  color51 default bold
color " 3 files changed"  color51 default bold
color " 4 files changed"  color51 default bold
color " 5 files changed"  color51 default bold
color " 6 files changed"  color51 default bold
color " 7 files changed"  color51 default bold
color " 8 files changed"  color51 default bold
color " 9 files changed"  color51 default bold
color " 10 files changed" color51 default bold

color "index "             blue   default
color "old file mode "     yellow default
color "new file mode "     yellow default
color "deleted file mode " yellow default
color "copy from "         yellow default
color "copy to "           yellow default
color "rename from "       yellow default
color "rename to "         yellow default

# Can define new for: pager, blob, diff, stage
#
# Prefix the name of a view to set a color only for that view, e.g.
#      `color grep.file     blue  default`
#
# As an example, this setting will to color Signed-off-by lines with a
# yellow foreground color and use the default background color.
#
#       color "    Signed-off-by" yellow  default
#
# Note the four leading spaces in the string to match. This is because
# Git automatically indents commit messages by four spaces.

# color "similarity "   yellow  default
# color "dissimilarity "    yellow  default
# color "\ No newline at end of file" blue  default
# color "diff-tree "    blue  default
# color "TaggerDate: "    yellow  default
# color "Refs: "      red default
# color "Reflog: "    red default
# color "Reflog message: "  yellow  default
# color "stash@{"     magenta default
# color "    Signed-off-by:"  yellow  default
# color "    Acked-by:"   yellow  default
# color "    Reviewed-by:"  yellow  default
# color "    Helped-by:"    yellow  default
# color "    Reported-by:"  yellow  default
# color "    Mentored-by:"  yellow  default
# color "    Suggested-by:" yellow  default
# color "    Cc:"     yellow  default
# color "    Noticed-by:"   yellow  default
# color "    Tested-by:"    yellow  default
# color "    Improved-by:"  yellow  default
# color "    Thanks-to:"    yellow  default
# color "    Based-on-patch-by:"  yellow  default
# color "    Contributions-by:" yellow  default
# color "    Co-authored-by:" yellow  default
# color "    Requested-by:" yellow  default
# color "    Original-patch-by:"  yellow  default
# color "    Inspired-by:"  yellow  default
# color default     default default normal
# color cursor      white green bold
# color status      green default
# color delimiter     magenta default
# color date      blue  default
# color mode      cyan  default
# color id      magenta default
# color overflow      red default
# color header      yellow  default
# color section     cyan  default
# color directory     yellow  default
# color file      default default
# color grep.file     blue  default
# color file-size     default default
# color line-number   cyan  default
# color title-blur    white blue
# color title-focus   white blue  bold
# color main-commit   default default
# color main-annotated    default default bold
# color main-tag      magenta default bold
# color main-local-tag    magenta default
# color main-remote   yellow  default
# color main-replace    cyan  default
# color main-tracked    yellow  default bold
# color main-ref      cyan  default
# color main-head     cyan  default bold
# color stat-none     default default
# color stat-staged   magenta default
# color stat-unstaged   magenta default
# color stat-untracked    magenta default
# color help-group    blue  default
# color help-action   yellow  default
# color palette-0     magenta default
# color palette-1     yellow  default
# color palette-2     cyan  default
# color palette-3     green default
# color palette-4     default default
# color palette-5     white default
# color palette-6     red default
# color palette-7     magenta default bold
# color palette-8     yellow  default bold
# color palette-9     cyan  default bold
# color palette-10    green default bold
# color palette-11    default default bold
# color palette-12    white default bold
# color palette-13    red default bold
# color graph-commit    blue  default
# color search-result   black yellow
#
# Mappings for colors read from git configuration.
# Set to "no" to disable.
set git-colors = no
# set git-colors = \
#   branch.current=main-head \
#   branch.local=main-ref \
#   branch.plain=main-ref \
#   branch.remote=main-remote \
#   \
#   diff.meta=diff-header \
#   diff.meta=diff-index \
#   diff.meta=diff-oldmode \
#   diff.meta=diff-newmode \
#   diff.frag=diff-chunk \
#   diff.old=diff-del \
#   diff.new=diff-add \
#   \
#   diff-highlight.oldHighlight=diff-del-highlight \
#   diff-highlight.newHighlight=diff-add-highlight \
#   \
#   grep.filename=grep.file \
#   grep.linenumber=grep.line-number \
#   grep.separator=grep.delimiter \
#   \
#   status.branch=status.header \
#   status.added=stat-staged \
#   status.updated=stat-staged \
#   status.changed=stat-unstaged \
#   status.untracked=stat-untracked
# ]]]

# === Unbound Keys ======================================================= [[[
# KEYS:
#   <Esc>...
#   &*=

# bind generic {  back
# bind generic }  back
# bind generic (  back
# bind generic )  back
# bind generic <Hash> :toggle line-number   # toggle line numbers
# bind generic  -       move-page-up
# bind generic  R      refresh     # reload and refresh view
# ]]]
# ]]]

# === TIPS: ============================================================== [[[

# === USAGE ============================================================== [[[
# $ tig --after="May 5th" --before="2006-05-16 15:44"
# $ tig tag-1.0..tag-2.0
# $ tig origin..HEAD

# All comits reachable from tag-2.0 but not tag-1.0:
#    $ tig tag-1.0..tag-2.0
# Prune commits of tags:
#    $ tig tag-2.0 ^tag-1.0
# Show at most 20 commits from last month that changed files in Documentation/ directory:
#    $ tig --since=1.month -n20 -- Documentation/
# Query changes across all references:
#    $ tig --all --since=1.week -- Makefile

# Display commits from one or more branches:   $ tig test master
# Display differences between two branches:    $ tig test..master
# ]]]

# === DEBUGGING ========================================================== [[[
# TIG_TRACE=/tmp/tig.log tig
# ]]]

# ]]]

# vim: ft=tmux:et:sw=4:ts=4:sts=2:fdm=marker:fmr=[[[,]]]:
