問(wèn)題
在使用 tig 命令時(shí),默認(rèn)在 main-view 的界面中是沒(méi)有 commit-ID 數(shù)據(jù)的,只有選中某個(gè) commit 才會(huì)在底部出現(xiàn)當(dāng)條 commit 的 commit-ID,對(duì)于有時(shí)想一眼看清log的整體 commit-ID 信息很不方便。
默認(rèn) tig 的 main-view 界面如下:

main-view 配置
通過(guò)man tig,發(fā)現(xiàn) tig 是可以提供一個(gè) tigrc 配置文件的!

有配置文件就應(yīng)該有對(duì)應(yīng)的配置, man 里提供的太少信息,網(wǎng)上找到設(shè)置的對(duì)應(yīng)網(wǎng)址說(shuō)明:
http://jonas.nitro.dk/tig/tigrc.5.html
里面說(shuō)的比較清楚,main-view 支持的 設(shè)置有:
- author: 作者
- date: 日期
- commit-title: commit 信息
- id: commit-ID
- line-number: 行號(hào)
可以看出,我們需要配置的支持是 id,因此可以在 $HOME/.tigrc 里增加配置:
set main-view-id = yes,color
表示開(kāi)啟 commit-ID,同時(shí)開(kāi)啟顏色支持。打開(kāi) tig 效果如下:

但我希望能把 commit-ID 放到 commit 信息旁邊,所以需要重新配置 main-view 的顯示:
# 重設(shè) main-view,增加 commit Id 信息
set main-view = date:default author:abbreviated id:yes,color \
line-number:no,interval=1 \
commit-title:graph=v2,refs=yes,overflow=no
配置的參數(shù)意義,請(qǐng)參考 http://jonas.nitro.dk/tig/tigrc.5.html 里面的說(shuō)明。配置后顯示如下:

此時(shí)目的達(dá)到。
修改其他配置
tig 默認(rèn)的 tab-size 顯示是 8 個(gè)空格,如果修改的話,在 $HOME/.tigrc 中增加:
set tab-size = 4
界面的移動(dòng):
# 綁定一下常用操作
bind generic H scroll-left
bind generic L scroll-right
bind main G move-last-line
bind generic G move-last-line
bind generic J move-page-down
bind generic K move-page-up
bind generic <C-f> move-page-down
bind generic <C-b> move-page-up
bind generic g none
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
我的 $HOME/.tigrc 配置如下, GitHub 鏈接 【tigrc】
#
# To use these keybindings copy the file to your HOME directory and include
# it from your ~/.tigrc file:
# 配置參考: http://jonas.nitro.dk/tig/tigrc.5.html
# 綁定一下常用操作
# bind generic j move-down
# bind generic k move-up
bind generic H scroll-left
bind generic L scroll-right
bind main G move-last-line
bind generic G move-last-line
bind generic J move-page-down
bind generic K move-page-up
bind generic <C-f> move-page-down
bind generic <C-b> move-page-up
bind generic g none
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
# 設(shè)置 tab-size 為 4,默認(rèn)為 8
set tab-size = 4
# 設(shè)置 blame-view 界面顯示
set blame-view-id = yes,color
set blame-view-line-number = yes,interval=1
# 重設(shè) main-view,增加 commit Id 信息
set main-view = date:default author:abbreviated id:yes,color \
line-number:no,interval=1 \
commit-title:graph=v2,refs=yes,overflow=no
# 重設(shè) tree-view 界面
set tree-view = date:default author:abbreviated id:yes,color \
line-number:no,interval=5 \
mode file-size:units,width=0 \
file-name
關(guān)注 【https://github.com/bbxytl/b-dotfiles】 了解更多好用的配置。