Search code examples
gitkgit-for-windows

Any way to control the default view of gitk


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?


Solution

  • 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.