TIGRC(5) | Tig Manual | TIGRC(5) |
tigrc - Tig configuration file
set variable = value bind keymap key action color area fgcolor bgcolor [attributes] source path
You can permanently set an option by putting it in the ~/.tigrc file. The file consists of a series of commands. Each line of the file may contain only one command. Commands can span multiple lines if each line is terminated by a backslash (\) character.
The hash mark (#) is used as a comment character. All text after the comment character to the end of the line is ignored. You can use comments to annotate your initialization file.
Certain options can be manipulated at runtime via the option menu. In addition, options can also be toggled with the :toggle prompt command or by entering the configuration command into the prompt.
In some environments, a user’s configuration will be stored in the alternate location $XDG_CONFIG_HOME/tig/config. For brevity, this document will refer only to ~/.tigrc.
Alternatively to using ~/.tigrc, Tig options can be set by putting them in one of the Git configuration files, which are read by Tig on startup. See git-config(1) for which files to use. The following example show the basic syntax to use for settings, bindings and colors.
[tig] show-changes = true [tig "color"] cursor = yellow red bold [tig "bind"] generic = P parent
In addition to tig-specific options, the following Git options are read from the Git configuration:
color.*
core.abbrev
core.editor
core.worktree
gui.encoding
i18n.commitencoding
A few selective variables can be configured via the set command. The syntax is:
set variables = value
Examples:
set commit-order = topo # Order commits topologically set git-colors = no # Do not read Git's color settings. set horizontal-scroll = 33% # Scroll 33% of the view width set blame-options = -C -C -C # Blame lines from other files # Wrap branch names with () and tags with <> set reference-format = (branch) <tag> # Configure blame view columns using command spanning multiple lines. set blame-view = \
date:default \
author:abbreviated \
file-name:auto \
id:yes,color \
line-number:yes,interval=5 text
Or in the Git configuration files:
[tig]
line-graphics = no # Disable graphics characters
tab-size = 8 # Number of spaces per tab
The type of variables is either bool, int, string, or mixed.
Valid bool values
Valid int values
Valid string values
Valid mixed values
The following variables can be set:
diff-options (string)
blame-options (string)
log-options (string)
main-options (string)
reference-format (string)
line-graphics (mixed) [ascii|default|utf-8|auto|<bool>]
truncation-delimiter (mixed) [utf-8|<string>]
horizontal-scroll (mixed)
git-colors (list)
show-notes (mixed) [<reference>|<bool>]
show-changes (bool)
show-untracked (bool)
vertical-split (mixed) [auto|<bool>]
split-view-height (mixed)
split-view-width (mixed)
status-show-untracked-dirs (bool)
status-show-untracked-files (bool)
tab-size (int)
diff-context (int)
diff-highlight (mixed)
ignore-space (mixed) [no|all|some|at-eol|<bool>]
Warning: when ignore-space is set to some, all or at-eol, then the status-update and status-revert may fail when updating or reverting chunks containing lines with space changes. Similarly, stage-update-line may fail when updating a line adjacent to a line with space changes
commit-order (enum) [auto|default|topo|date|author-date|reverse]
ignore-case (enum) [no|yes|smart-case]
mailmap (bool)
wrap-lines (bool)
focus-child (bool)
send-child-enter (bool)
editor-line-number (bool)
history-size (int)
mouse (bool)
mouse-scroll (int)
mouse-wheel-cursor (bool)
pgrp (bool)
start-on-head (bool)
refresh-mode (mixed) [manual|auto|after-command|periodic|<bool>]
refresh-interval (int)
file-args (args)
rev-args (args)
The view settings define the order and options for the different columns of a view. Each view setting expects a space-separated list of column specifications. Column specifications starts with the column type, and can optionally be followed by a colon (:) and a list of column options. E.g. the following column specification defines an author column displaying the author email and with a fixed width of 20 characters: author:email,width=20.
The first option value in a column specification is always the display option. When no display value is given, yes is assumed. For display options expecting an enumerated value this will automatically resolve to the default enum value. For example, file-name will automatically have its display setting resolve to auto.
Specifications can also be given for a single column, for example to override the defaults in the system tigrc file. To override a single column, use the column name as a suffix after the view setting name, e.g. main-view-date will allow to set the date in the main view.
Examples:
# Enable both ID and line numbers in the blame view set blame-view = date:default author:full file-name:auto id:yes,color \
line-number:yes,interval=5 text # Change grep view to be similar to `git grep` format set grep-view = file-name:yes line-number:yes,interval=1 text # Show file sizes as units set tree-view = line-number:no,interval=5 mode author:full \
file-size:units date:default id:no file-name # Show line numbers for every 10th line in the pager view set pager-view = line-number:yes,interval=10 text # Shorthands to change view settings for a previously defined column set main-view-date = custom set main-view-date-format = "%Y-%m-%d %H:%M" set blame-view-line-number = no # Use Git's default commit order, even when the commit graph is enabled. set commit-order = default
The following list shows which the available view settings and what column types they support:
blob-view, diff-view, log-view, pager-view, stage-view
blame-view
grep-view
main-view, reflog-view
refs-view
stash-view
status-view
tree-view
Supported column types and their respective column options:
author
commit-title
date
file-name
file-size
id
line-number
mode
ref
status
text
All column options can be toggled. For display options, use the option name as the prefix followed by a dash and the column name. E.g. :toggle author-display will toggle the display option in the author column. For all other options use the column name followed by a dash and then the option name as the suffix. E.g. :toggle commit-title-graph will toggle the graph option in the commit-title column. Alternatively, use the option menu to manipulate options.
Using bind commands, keys can be mapped to an action when pressed in a given key map. The syntax is:
bind keymap key action
Examples:
# Add keybinding to quickly jump to the next diff chunk in the stage view bind stage <Enter> :/^@@ # Disable the default mapping for running git-gc bind generic G none # User-defined external command to amend the last commit bind status + !git commit --amend # User-defined internal command that reloads ~/.tigrc bind generic S :source ~/.tigrc # UTF8-encoded characters can be used as key values. bind generic ø @sh -c "printf '%s' %(commit) | pbcopy"
Or in the Git configuration files:
[tig "bind"]
# 'unbind' the default quit key binding
main = Q none
# Cherry-pick current commit onto current branch
generic = C !git cherry-pick %(commit)
Keys are mapped by first searching the keybindings for the current view, then the keybindings for the generic keymap, and last the default keybindings. Thus, the view keybindings override the generic keybindings which override the built-in keybindings.
Keybindings at the line-entry prompt are typically governed by the readline library, and are configured separately in ~/.inputrc. See readline(1). Tig respects but does not require an $if tig section in ~/.inputrc.
Keymaps
Key values
<Enter>, <Space>, <Backspace>, <Tab>, <Escape> or <Esc>, <Left>, <Right>, <Up>, <Down>, <Insert> or <Ins>, <Delete> or <Del>, <Hash>, <LessThan> or <LT>, <Home>, <End>, <PageUp> or <PgUp>, <PageDown> or <PgDown>, <ScrollBack> or <SBack>, <ScrollFwd> or <SFwd>, <ShiftTab> or <BackTab>, <ShiftLeft>, <ShiftRight>, <ShiftDelete> or <ShiftDel>, <ShiftHome>, <ShiftEnd>, <SingleQuote>, <DoubleQuote>, <F1> ... <F19>
To define key mappings with the Ctrl key, use <Ctrl-key>. In addition, key combos consisting of an initial Escape key followed by a normal key value can be bound using <Esc>key.
Examples:
bind main R refresh bind main <Down> next bind main <Ctrl-f> scroll-page-down bind main <Esc>o options bind main <ShiftTab> parent
Notes
Actions
These actions start with one or more of the following option flags followed by the command that should be executed.
! | Run the command in the foreground with output shown. |
@ | Run the command in the background with no output. |
+ | Run the command synchronously, and echo the first line of output to the status bar. |
? | Prompt the user before executing the command. |
< | Exit Tig after executing the command. |
> | Re-open Tig instantly in the last displayed view after executing the command. |
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.
Note that if you want to use pipes or redirection in your commands then you must run them in a subshell, i.e. embed your commands in sh -c '<commands>'.
Browsing state variables
User-defined commands can optionally refer to Tig’s internal state using the following variable names, which are substituted before commands are run:
%(head) | The currently viewed head ID. Defaults to HEAD |
%(commit) | The currently selected commit ID. |
%(blob) | The currently selected blob ID. |
%(branch) | The currently selected branch name. |
%(remote) | The currently selected remote name. For remote branches %(branch) will contain the branch name. |
%(tag) | The currently selected tag name. |
%(refname) | The currently selected reference name including the remote name for remote branches. |
%(stash) | The currently selected stash name. |
%(directory) | The current directory path in the tree view or "." if undefined. |
%(file) | The currently selected file. |
%(file_old) | The old filename of the currently selected file. |
%(lineno) | The currently selected line number. Defaults to 0. |
%(lineno_old) | The currently selected line number, before the diff was applied. Defaults to 0. |
%(ref) | The reference given to blame or HEAD if undefined. |
%(revargs) | The revision arguments passed on the command line. |
%(fileargs) | The file arguments passed on the command line. |
%(cmdlineargs) | All other options passed on the command line. |
%(diffargs) | Options from diff-options or TIG_DIFF_OPTS used by the diff and stage view. |
%(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. |
%(prompt) | Prompt for the argument value. Optionally specify a custom prompt using "%(prompt Enter branch name: )" |
%(text) | The text of the currently selected line. |
%(repo:head) | The name of the checked out branch, e.g. master |
%(repo:head-id) | The commit ID of the checked out branch. |
%(repo:remote) | The remote associated with the checked out branch, e.g. origin/master. |
%(repo:cdup) | The path to change directory to the repository root, e.g. ../ |
%(repo:prefix) | The path prefix of the current work directory, e.g subdir/. |
%(repo:git-dir) | The path to the Git directory, e.g. /src/repo/.git. |
%(repo:worktree) | The worktree path, if defined. |
%(repo:is-inside-work-tree) | Whether Tig is running inside a work tree, either true or false. |
Examples:
# 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'
Advanced shell-like commands
If your command requires use of dynamic features, such as subshells, expansion of environment variables and process control, this can be achieved by using a shell command:
Example 1. Configure a binding to copy the current commit ID to the clipboard.
bind generic I @sh -c "echo -n %(commit) | xclip -selection c"
Or by using a combination of Git aliases and Tig external commands. The following example entries can be put in either the .gitconfig or .git/config file:
Example 2. Git configuration which binds Tig keys to Git command aliases.
[alias]
gitk-bg = !"gitk HEAD --not $(git rev-parse --remotes) &"
publish = !"for i in origin public; do git push $i; done" [tig "bind"]
generic = V @git gitk-bg
generic = > !git publish
Actions beginning with a : will be run and interpreted as internal commands and act similar to commands run via Tig’s prompt. Valid internal commands are configuration file options (as described in this document) and pager view commands. Examples:
# Reload ~/.tigrc when 'S' is pressed bind generic S :source .tigrc # Change diff view to show all commit changes regardless of file limitations bind diff F :set diff-options = --full-diff # Show the output of git-reflog(1) in the pager view bind generic W :!git reflog # Search for previous diff (c)hunk and next diff header bind stage 2 :?^@@ bind stage D :/^diff --(git|cc) bind main I :toggle id # Show/hide the ID column bind diff D :toggle diff-options --minimal # Use minimal diff algorithm bind diff [ :toggle diff-context -3 # Decrease context (-U arg) bind diff ] :toggle diff-context +3 # Increase context bind generic V :toggle split-view-height -10% # Decrease split height
Similar to external commands, pager view commands can contain variable names that will be substituted before the command is run.
Valid action names are described below. Note, all action names are case-insensitive, and you may use -, _, and . interchangeably, e.g. "view-main", "View.Main", and "VIEW_MAIN" are the same.
View switching
view-main | Show main view |
view-diff | Show diff view |
view-log | Show log view |
view-reflog | Show reflog view |
view-tree | Show tree view |
view-blob | Show blob view |
view-blame | Show blame view |
view-refs | Show refs view |
view-status | Show status view |
view-stage | Show stage view |
view-stash | Show stash view |
view-grep | Show grep view |
view-pager | Show pager view |
view-help | Show help view |
View manipulation
enter | Enter and open selected line |
back | Go back to the previous view state |
next | Move to next |
previous | Move to previous |
parent | Move to parent |
view-next | Move focus to the next view |
refresh | Reload and refresh view |
maximize | Maximize the current view |
view-close | Close the current view |
view-close-no-quit | Close the current view without quitting |
quit | Close all views and quit |
View-specific actions
status-update | Stage/unstage chunk or file changes |
status-revert | Revert chunk or file changes |
status-merge | Merge file using external tool |
stage-update-line | Stage/unstage single line |
stage-update-part | Stage/unstage part of a chunk |
stage-split-chunk | Split current diff chunk |
Cursor navigation
move-up | Move cursor one line up |
move-down | Move cursor one line down |
move-page-up | Move cursor one page up |
move-page-down | Move cursor one page down |
move-half-page-up | Move cursor half a page up |
move-half-page-down | Move cursor half a page down |
move-first-line | Move cursor to first line |
move-last-line | Move cursor to last line |
move-next-merge | Move cursor to next merge commit |
move-prev-merge | Move cursor to previous merge commit |
Scrolling
scroll-line-up | Scroll one line up |
scroll-line-down | Scroll one line down |
scroll-page-up | Scroll one page up |
scroll-page-down | Scroll one page down |
scroll-half-page-up | Scroll half a page up |
scroll-half-page-down | Scroll half a page down |
scroll-first-col | Scroll to the first line columns |
scroll-left | Scroll two columns left |
scroll-right | Scroll two columns right |
Searching
search | Search the view |
search-back | Search backwards in the view |
find-next | Find next search match |
find-prev | Find previous search match |
Misc
edit | Open in editor |
prompt | Open the prompt |
options | Open the options menu |
screen-redraw | Redraw the screen |
stop-loading | Stop all loading views |
show-version | Show version information |
none | Do nothing |
Color commands control highlighting and the user interface styles. If your terminal supports color, these commands can be used to assign foreground and background combinations to certain areas. Optionally, an attribute can be given as the last parameter. The syntax is:
color area fgcolor bgcolor [attributes]
Examples:
# Override the default terminal colors to white on black. color default white black # Diff colors color diff-header yellow default color diff-index blue default color diff-chunk magenta default color "Reported-by:" green default # View-specific color color tree.date black cyan bold
Or in the Git configuration files:
[tig "color"]
# A strange looking cursor line
cursor = red default underline
# UI colors
title-blur = white blue
title-focus = white blue bold # View-specific color [tig "color.tree"]
date = cyan default bold
Area names
Color names
Colors can also be specified using the keywords color0, color1, ..., colorN-1 (where N is the number of colors supported by your terminal). This is useful when you remap the colors for your display or want to enable colors supported by 88-color and 256-color terminals. Note that the color prefix is optional. If you prefer, you can specify colors directly by their numbers 0, 1, ..., N-1 instead, just like in the configuration file of Git.
Attribute names
The colors and attributes to be used for the text that is not highlighted or that specify the use of the default terminal colors can be controlled by setting the default color option.
Table 1. General
default | Override default terminal colors (see above). |
cursor | The cursor line. |
status | The status window showing info messages. |
title-focus | The title window for the current view. |
title-blur | The title window of any backgrounded view. |
search-result | Highlighted search result. |
delimiter | Delimiter shown for truncated lines. |
header | The view header lines. Use status.header to color the staged, unstaged, and untracked sections in the status view. Use help.header to color the keymap sections in the help view. |
line-number | Line numbers. |
id | The commit ID. |
date | The author date. |
author | The commit author. |
mode | The file mode holding the permissions and type. |
overflow | Title text overflow. |
directory | The directory name. |
file | The file name. |
file-size | File size. |
Table 2. Main view colors
graph-commit | The commit dot in the revision graph. |
palette-[0-13] | 14 different colors, used for distinguishing branches or commits. By default, the palette uses the ASCII colors, where the second half of them have the bold attribute enabled to give a brighter color. Example: palette-0 = red |
main-commit | The commit comment. |
main-annotated | The commit comment of an annotated commit. |
main-head | Label of the current branch. |
main-remote | Label of a remote. |
main-tracked | Label of the remote tracked by the current branch. |
main-tag | Label of a signed tag. |
main-local-tag | Label of a local tag. |
main-ref | Label of any other reference. |
main-replace | Label of replaced reference. |
Table 3. Status view
stat-none | Empty status label. |
stat-staged | Status flag of staged files. |
stat-unstaged | Status flag of unstaged files. |
stat-untracked | Status flag of untracked files. |
Table 4. Help view
help-group | Help group name. |
help-action | Help action name. |
Diff markup
diff-header, diff-chunk, diff-stat, diff-add, diff-add2, diff-del, diff-del2, diff-add-highlight, diff-del-highlight
Enhanced Git diff markup
diff-oldmode, diff-newmode, diff-copy-from, diff-copy-to, diff-similarity, diff-index
Pretty print commit headers
pp-refs, pp-reflog, pp-reflogmsg, pp-merge
Raw commit header
commit, parent, tree, author, committer
Commit message
Tree markup
tree-dir, tree-file
Source commands make it possible to read additional configuration files. Sourced files are included in-place, meaning when a source command is encountered the file will be immediately read. Any commands later in the current configuration file will take precedence.
If the given path does not exist, tig will proceed with a warning. Give the -q parameter to suppress the warning.
The syntax is:
source [-q] path
Examples:
source ~/.tig/colorscheme.tigrc source ~/.tig/keybindings.tigrc
Copyright (c) 2006-2014 Jonas Fonseca <jonas.fonseca@gmail.com[1]>
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
02/26/2022 | Tig 2.5.5 |