問題
在使用 tig 命令時,默認在 main-view 的界面中是沒有 commit-ID 數據的,只有選中某個 commit 才會在底部出現當條 commit 的 commit-ID,對于有時想一眼看清log的整體 commit-ID 信息很不方便。
默認 tig 的 main-view 界面如下:
F7319856E91A33F4B18888B368894617.jpg
main-view 配置
通過man tig
,發現 tig 是可以提供一個 tigrc 配置文件的!
8D996816BFC8C33C175DD77B0A479461.jpg
有配置文件就應該有對應的配置, man 里提供的太少信息,網上找到設置的對應網址說明:
http://jonas.nitro.dk/tig/tigrc.5.html
里面說的比較清楚,main-view 支持的 設置有:
- author: 作者
- date: 日期
- commit-title: commit 信息
- id: commit-ID
- line-number: 行號
可以看出,我們需要配置的支持是 id,因此可以在 $HOME/.tigrc
里增加配置:
set main-view-id = yes,color
表示開啟 commit-ID,同時開啟顏色支持。打開 tig 效果如下:
81F6A90C8C2EB174BA200D1721B87998.jpg
但我希望能把 commit-ID 放到 commit 信息旁邊,所以需要重新配置 main-view 的顯示:
# 重設 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
配置的參數意義,請參考 http://jonas.nitro.dk/tig/tigrc.5.html 里面的說明。配置后顯示如下:
5D77DD2B6661102A79AB654C47B46A08.jpg
此時目的達到。
修改其他配置
tig 默認的 tab-size 顯示是 8 個空格,如果修改的話,在 $HOME/.tigrc
中增加:
set tab-size = 4
界面的移動:
# 綁定一下常用操作
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
# 設置 tab-size 為 4,默認為 8
set tab-size = 4
# 設置 blame-view 界面顯示
set blame-view-id = yes,color
set blame-view-line-number = yes,interval=1
# 重設 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
# 重設 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
關注 【https://github.com/bbxytl/b-dotfiles】 了解更多好用的配置。