I use gitk from Git for Windows. By default it seems to open with a view that only displays the currently checked out branch.
I have a different saved view which is the one that I use 90% of the time.
I normally open gitk from the cmd line (by running gitk &), and then have to change the view.
Is there any way to configure gitk to use my preferred view by default?
There does not appear to be a feature for this in gitk, however it is pretty easy to manually patch gitk to switch to the first permanent view (located for me in c:\Program Files\Git\mingw64\bin\gitk):
if {[info exists permviews]} {
foreach v $permviews {
set n $nextviewnum
incr nextviewnum
set viewname($n) [lindex $v 0]
set viewfiles($n) [lindex $v 1]
set viewargs($n) [lindex $v 2]
set viewargscmd($n) [lindex $v 3]
set viewperm($n) 1
set viewchanged($n) 0
addviewmenu $n
}
# add these two lines
set curview [expr {$curview + 1}]
set selectedview $curview
}
This will always select the first permanent view you defined as the default view. If you want to reorder the views, the (hidden) config file is at %USERPROFILE%\.config\git\gitk. The setting is called permviews.
Thanks, @mrexodia. One improvement I was able to make on your answer was to guard the additional lines so that they won't run if cmd-line args were provided:
if {$curview==0} {
set curview 1
set selectedview $curview
}
Also, thanks to this thread for helping me understand that I had to run Git Bash as Administrator to be able to modify the gitk file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With