7

Some days ago I bumped into this picture of git gui with a dark theme.

enter image description here

I have went through the documentation, search the menus for it and asked DuckDuckGo, but so far I have not figured out how to change the theme. How can it be done?

Edit: I work on Ubuntu 16.04 with a dark theme. Git gui completes ignores the theme settings of my DE, therefore I could not imagine it could be related, as kowsky suggests below.

Luís de Sousa
  • 5,765
  • 11
  • 49
  • 86
  • I am using a gnome extension called "true color invert" `super+i` on a single window. not perfect but does the trick of avoiding burning my eyes ;) – Aquarius Power Apr 17 '23 at 00:50

4 Answers4

4

I suppose you took that picture from here?

The user issuing the screenshots states that

[...] I'm using Dark theme for my Windows, [...]

and

Git-GUI (main window) must use Windows native colors [...]

Thus, I suspect he achieved this "dark Theme" by setting his default windows color theme accordingly.

kowsky
  • 12,647
  • 2
  • 28
  • 41
2

There is a github issue with a start on an "official" dark mode for git gui. As of this writing, current suggestions include editing git-gui.tcl and add the following lines just after the pave_toplevel . line, which is around line number 869:

ttk::style theme use default
ttk::style configure TFrame -background #333
ttk::style configure TLabelframe -background #333
ttk::style configure TLabelframe.Label -background #333 -foreground #fff
ttk::style configure TPanedwindow  -background #333
ttk::style configure EntryFrame -background #333
ttk::style configure TScrollbar -background #666 -troughcolor #444 -arrowcolor #fff -arrowsize 15
ttk::style map TScrollbar -background [list active #333 disabled #000]
ttk::style configure TLabel -background #333 -foreground #fff
ttk::style configure TButton -background #333 -foreground #fff -borderwidth 2 -bordercolor #fff
ttk::style map TButton -background [list active #555 disabled #111 readonly #000]
ttk::style configure TCheckbutton -background #333 -foreground #fff -indicatorbackground #666 -indicatorcolor #fff
ttk::style map TCheckbutton -background [list active #555 disabled #111 readonly #000]
ttk::style configure TEntry -fieldbackground #333 -background #333 -foreground #fff -insertcolor #fff
ttk::style configure TRadiobutton -background #333 -foreground #fff
ttk::style map TRadiobutton -background [list active #555 disabled #111 readonly #000]
option add *TCombobox*Listbox.background #333 interactive
option add *TCombobox*Listbox.foreground #fff interactive
option add *TCombobox*Listbox.selectBackground blue interactive
option add *TCombobox*Listbox.selectForeground #fff interactive
option add *Listbox.Background #333 interactive
option add *Listbox.Foreground #fff interactive
option add *Text.Background #333 interactive
option add *Text.Foreground #fff interactive
ttk::style configure TSpinbox -fieldbackground #333 -background #333 -foreground #fff -insertcolor #fff -arrowcolor #fff \
    .vpane.lower.commarea.buffer.frame.t \
    configure -background #0d1117 -foreground #fff -insertbackground #fff \
    .vpane.lower.diff.body.t configure -background #0d1117 -foreground #fff \
    .vpane.files.workdir.list configure -background #0d1117 -foreground #fff \
    .vpane.files.index.list configure -background #0d1117 -foreground #fff \
    .about_dialog.git_logo configure -background #333

The lines above will change a vast majority of things. To adjust the border/outline of the sections insert the following lines above the "Load window state" comment further down in the file:

.vpane.files.index.list configure -background #333 -highlightbackground #333 -highlightthickness 1
.vpane.files.workdir.list configure -background #333 -highlightbackground #333 -highlightthickness 1
.vpane.lower.diff.body.t configure -background #333 -highlightbackground #333 -highlightthickness 1
.vpane.lower.commarea.buffer.frame.t configure -background #333 -highlightbackground #333 -highlightthickness 1

FWIW, I needed the above on Windows. On mac, git gui seems to follow the system them - at least git version 2.32 from brew.

John Cummings
  • 1,949
  • 3
  • 22
  • 38
1

The colours are hardcoded, defined in a file called choose_repository.tcl. Not sure about Ubuntu but in Windows it's located in C:\Program Files\Git\mingw64\share\git-gui\lib\choose_repository.tcl. Change the colours to what you like. Mine looks like this with this patch:

Git Gui



@@ -91,17 +91,18 @@ constructor pick {} {
    ${NS}::frame $w_body
    text $opts \
        -cursor $::cursor_ptr \
        -relief flat \
        -background [get_bg_color $w_body] \
+       -foreground lime \
        -wrap none \
        -spacing1 5 \
        -width 50 \
        -height 3
    pack $opts -anchor w -fill x

-   $opts tag conf link_new -foreground blue -underline 1
+   $opts tag conf link_new -underline 1
    $opts tag bind link_new <1> [cb _next new]
    $opts insert end [mc "Create New Repository"] link_new
    $opts insert end "\n"
    if {$m_repo ne {}} {
        $m_repo add command \
@@ -110,11 +111,11 @@ constructor pick {} {
            -label [mc "New..."]
        bind $top <$M1B-n> [cb _next new]
        bind $top <$M1B-N> [cb _next new]
    }

-   $opts tag conf link_clone -foreground blue -underline 1
+   $opts tag conf link_clone -underline 1
    $opts tag bind link_clone <1> [cb _next clone]
    $opts insert end [mc "Clone Existing Repository"] link_clone
    $opts insert end "\n"
    if {$m_repo ne {}} {
        if {[tk windowingsystem] eq "win32"} {
@@ -128,11 +129,11 @@ constructor pick {} {
            -label [mc "Clone..."]
        bind $top <$M1B-[string tolower $key]> [cb _next clone]
        bind $top <$M1B-[string toupper $key]> [cb _next clone]
    }

-   $opts tag conf link_open -foreground blue -underline 1
+   $opts tag conf link_open -underline 1
    $opts tag bind link_open <1> [cb _next open]
    $opts insert end [mc "Open Existing Repository"] link_open
    $opts insert end "\n"
    if {$m_repo ne {}} {
        $m_repo add command \
@@ -169,12 +170,12 @@ constructor pick {} {
            -background [get_bg_color $w_body.recentlabel] \
            -wrap none \
            -width 50 \
            -height $lenrecent
        $w_recentlist tag conf link \
-           -foreground blue \
-           -underline 1
+           -foreground yellow \
+           -underline 0
        set home $::env(HOME)
        if {[is_Cygwin]} {
            set home [exec cygpath --windows --absolute $home]
        }
        set home "[file normalize $home]/"

Plakhoy
  • 1,846
  • 1
  • 18
  • 30
  • 2
    Maybe it is located in `/usr/share/git-gui/lib/choose_repository.tcl`. At least, this is my guess. – dan1st Apr 09 '20 at 06:50
  • Looks like we are very close. Unfortunately that patch fail against the `choose_repository.tcl`. This file might be different across versions (I am using 2.17.1). Could you provide something more generic? – Luís de Sousa Apr 09 '20 at 09:10
  • @LuísdeSousa, were you able to find those lines? I added the patch to point you to the lines you need to change. The file will change over time but the relevant parts should still look similar to the ones in this diff – Plakhoy Apr 10 '20 at 19:30
  • I applied these lines by hand. Now there are a couple of lines in the splash screen that are portrayed in yellow. Apart from the GUI looks as before. – Luís de Sousa Apr 14 '20 at 18:47
1

Plakhoy's answer above shows how to style the choose_repository page. To change the rest of the application to dark mode follow my suggestions below. I do not have enough reputation to post images, but you can change a few lines of code to enable a dark mode for Git Gui.

This will create a black background with light (almost white) text.

File location: C:\Program Files\Git\mingw64\share\git-gui\lib\themed.tcl

themed.tcl lines 14-20 original settings (light mode).

proc sync_with_theme {} {  
    set base_bg             [ttk::style lookup . -background]  
    set base_fg             [ttk::style lookup . -foreground]  
    set text_bg             [ttk::style lookup Treeview -background]  
    set text_fg             [ttk::style lookup Treeview -foreground]  
    set select_bg           [ttk::style lookup Default -selectbackground]  
    set select_fg           [ttk::style lookup Default -selectforeground]  

In themed.tcl change lines 14-20 as follows (dark mode).

proc sync_with_theme {} {  
    set base_bg             #282a36  
    set base_fg             #f8f8f2  
    set text_bg             #282a36  
    set text_fg             #f8f8f2  
    set select_bg           #f8f8f2  
    set select_fg           #282a36
Justin B.
  • 9
  • 4
  • This gets the main window partially, but things like the branch visualization is unaffected. Probably just take some additional changes to other tcl files, maybe branch.tcl – David Bradley Aug 23 '23 at 12:24