38

I'm running Xubuntu, (actually linux mint with xfce on top, but I suppose it's essentially the same thing)

I set my appearance theme to (a modified version of) MurrinaStormCloud, but if I run gitk, it uses ugly font rendering, ugly colors, ugly widgets.

I think tcl is the thing to blame here, but can I fix it?

Here's a picture for comparison between what firefox looks like under the current theme and what gitk looks like:

gitk ugly theme

2
  • 2
    nice that we have gitg, but I still vote this question up to see if anyone can solve tcl/tk ugliness. gitk is still more compact than gitg. Aug 27, 2009 at 20:07
  • @u0b34a0f6ae I agree gitg is too slow - I've done my best to make gitk fit into Ubuntu in 2022: superuser.com/a/1707378/41494
    – icc97
    Feb 28, 2022 at 19:10

10 Answers 10

25

gitk is implemented in tcl/tk. I've searched around but there doesn't seem to be much you can do; it is scolded as ugly on Linux everywhere. And apart from using a hideous toolkit, gitk has been growing worse for me as they put in more functions (mostly not used) the UI becomes even more confusing.

So I instead of a solution I recommend gitg, which is a similar tool, less mature, using GTK+.

6
  • 4
    +1 gitg didn't know about thatone Aug 26, 2009 at 20:43
  • I've heard about gitg. Sounds promising. Though, the thing is, gitk looked OK on windows, if I remember correctly.
    – hasen
    Aug 27, 2009 at 0:14
  • gitg is much nicer. +1 for that!
    – crazy2be
    May 14, 2011 at 17:58
  • 2
    All tcl/tk apps look hideous, unfortunately.
    – jpaugh
    Dec 3, 2011 at 19:07
  • 2
    @jpaugh No, not all, just those that don't use ttk styles, the Tk 'theme' system.
    – Lloeki
    Dec 5, 2012 at 15:00
14

tcl/tk 8.5 is actually themeable and looks rather native on Windows 7 and apparently on Mac. Less care seems to have been given to write theme engine bridges for it under linux, but you can do one of three things:

To have it persist between reboots add the line *TkTheme: clam to ~/.Xresources, but I'm not sure if that's read whether you launch your desktop environment with startx or not.

Under Ubuntu 11.04 it was pretty easy, adapt the tcl/tk library paths as needed (some people have reported that those instructions are outdated):

$./configure --with-tcl=/usr/lib/tcl8.5/ --with-tk=/usr/lib/tk8.5/

$make

$sudo checkinstall

checkinstall being for creating a quick .deb instead of installing directly, keeps the system tidy.

Then afterwards as above, get tk to use your qt themes:

$echo '*TkTheme: tileqt' | xrdb -merge -
  • There's also a tile-gtk in the same sourceforge repo as tile-qt, but it's thouroughly out-of date. I did manage to build it and install it after much fiddling but the visual results were messy - not recommended.
10

To fix this the Debian (Ubuntu) way:

$ sudo apt-get install tk8.5
$ sudo update-alternatives --config wish

And then pick the wish8.5 alternative.

6
  • That's much nicer looking, although it still doesn't follow the Gtk+ or Qt theme. +1
    – crazy2be
    May 14, 2011 at 17:54
  • Thank you, I didn't expect perfect desktop integration but 8.5 does look much much better that the ones in 8.4. May 20, 2011 at 20:36
  • This answer should be up there! Simply changing tk to 8.5 greatly improves the looks of gitk. Apr 2, 2013 at 13:17
  • 5
    This is what I get on Ubuntu 14.04: update-alternatives: error: no alternatives for wish Apr 12, 2016 at 9:28
  • 1
    This no longer works - perhaps due to changes in Debian-based distributions over the years. Tried it with Debian 9.
    – einpoklum
    Jan 7, 2019 at 13:32
9

Gabriel Morin's post is good, but tile-qt doesn't build anymore with those instructions and, though the blog post he linked to (mine, by the way) still works, it's no longer the best solution I know.

For people who want something better than the "clam" theme, PySolFC includes a Clearlooks theme for Ttk and I wrote another blog post which explains how to install it.

Here are the relevant parts of it, adapted for a Lubuntu user (which I now am):

# Get the theme
sudo apt-get install pysolfc

# Copy it into your user profile to not rely on PySolFC's presence
mkdir -p ~/.local/share/tkthemes
cp -r /usr/share/games/pysolfc/themes/clearlooks ~/.local/share/tkthemes/

# (optional) Remove PySolFC now
sudo apt-get remove pysolfc
sudo apt-get autoremove

# Add it to Ttk's search path
echo "export TCLLIBPATH=~/.local/share/tkthemes" >> ~/.xsessionrc

# Set the theme
echo "*TkTheme: clearlooks" >> ~/.Xresources

# Test it in this specific terminal window
export TCLLIBPATH=~/.local/share/tkthemes
xrdb -merge ~/.Xresources
git gui     # gitk's "this isn't a repo" dialog is always ugly

# ...and then log out and back in to apply .xsessionrc for the whole desktop

There are some widgets which are still ugly (the menu bar and the SHA1 ID: text, which needs to be patched in gitk to be themable) but I don't know enough Tcl/Tk to patch things.

(And I've heard rumors that the menu bar wasn't made themable because it's delegated to the OS to draw on Windows and MacOS)

4
  • I like the fact that you noticed the link to your blog and came back with an improved solution :) . If I find some time to set myself up again I might update the build instructions for tileqt, since I imagine it's still a viable alternative to what you propose. Aug 25, 2014 at 15:28
  • This script indeed does something, it is just not visible. Still get the ugly light coloured theme. Tested on Ubuntu 14.04. Apr 13, 2016 at 9:13
  • Well, I'm on a Lubuntu 14.04 system that got frankenstein'd into a partly Kubuntu 14.04 system and I can say that this works perfectly with git gui (which I use daily), so I have no idea what might be wrong on your end. This should fall firmly within the common core shared by all *buntu distros.
    – ssokolow
    Apr 14, 2016 at 3:23
  • Thank you for your blog posts btw, they're really helpful :)
    – icc97
    Mar 2, 2022 at 11:32
5

You cannot easily make gitk follow your other themes, but its appearance is fairly customisable.

As mentioned elsewhere you can choose your fonts manually. Nearly all colors are modifiable as well, in your ~/.gitk. Make sure gitk is not running while modifying this file though, as it overwrites the content at exit.

Here is what I have (my ~/.gitk file): enter image description here

6
  • 2
    (Disclaimer: I'm the maintainer.) There is now an official Dracula dark theme for gitk: draculatheme.com/gitk
    – Aurélien
    Apr 16, 2018 at 18:03
  • 1
    @Aurelien Good to see others using gitk theming, I wrote the commit that allows changing these parameters ;) (but Dracula has too high contrast for me. Nice job though!)
    – Gauthier
    Apr 16, 2018 at 18:14
  • Gauthier, @Aurelien: I tried placing the linked-to text in my ~/.gitk file - it had no effect.
    – einpoklum
    Jan 7, 2019 at 13:37
  • 2
    @einpoklum: personally I put this text in ~/.config/git/gitk instead of ~/.gitk. See draculatheme.com/gitk . Does this help? I don't know about other themes.
    – Aurélien
    Jan 14, 2019 at 14:42
  • 1
    @Aurelien: It does.
    – einpoklum
    Jan 14, 2019 at 14:49
2

as kaizer.se said gitk (and also git gui) is implemented using tcl/tk, tk is the widget toolkit and do not care about gtk-based themes (or any at all afaik). And no this is not something you can fix (well rewriting gitk to use gtk widget's is ofc not impossible but hardly a 'fix') other than replacing it with something else.

You can change the font's in the preferences to make it slightly better, I use:
Main font: Helvetica 9
Diff display font: Courier 9
User interface font: Helvetica 9

This looks a little better and not as broken as the default's, well for me.

1
  • In 2022, with Pop OS installed, you can switch to their fonts - Main font: Roboto Slab Regular 11 | Diff display font: Fira Mono Regular 11 | User interface font: Fira Sans Regular 10
    – icc97
    Feb 28, 2022 at 14:44
2

In my case, the correct version of tk and wish were installed on the system, and the problem arose from having installed anaconda.

The anaconda install script adds export PATH=":/path/to/anaconda3/bin:$PATH" to your ~/.bashrc, which causes the wish program installed there to take precedence.

Rewriting this line to export PATH="$PATH:/path/to/anaconda3/bin" allowed the system's wish to be executed by gitk, and solved the font problem.

1
  • This was helpful. Another workaround to bypass the anaconda version of wish is to setup a git alias something like: git config --global alias.gui2 '!/usr/bin/wish /usr/lib/git-core/git-gui --'. Then can type git gui2 at the command line to see the git gui with better fonts.
    – FuzzyWuzzy
    Apr 18, 2020 at 16:03
1

Its 2022, we're using Ubuntu/Pop OS 22.04, let's make gitk look like it should belong

tl;dr Here's a before and after, follow along if you like what you see and scroll to the bottom if you want to see what the pretty version looks like next to gitg:

before and after screenshot

Ok, it's 2022 and we still have these problems. But I tried gitg and it's pretty, but really annoyingly slow. gitk is fast and I like things that are fast, but I also like things as pretty, so I want to make gitk as pretty as it can be.

There is a helpful line that is repeated in many of these answers but it seems a bit too much like magic:

echo '*TkTheme: clam' | xrdb -merge -

How do I know if this will still work? Plus I like dummies guides :)

As of 2022 running Pop OS (Ubuntu 22.04) under the hood, the above command still works as does setting it in ~/.Xresources.

However it's still to much like magic, how do I know if it will work in the future?

I recommend reading Applying TK Themes to Git Gui. That explains a lot.

One of the things I don't want to do is have to compile anything.

Ok, so what has changed in a decade... tk is up to 8.6 and 8.7 is in alpha.

So if you don't have tk you can install it with:

sudo apt-get install tk8.6

For Pop OS 22.04 this is already installed though.

Note from this answer here however the below line doesn't work, or at least perhaps its not required:

sudo update-alternatives --config wish

What does work is wish itself. As per the blog post run:

wish

It weirdly opens a 'wish' window but also drops you into a new prompt %. Then as per the blog post you can carry on typing in the terminal:

$ wish
% info patchlevel
8.6.11
% ttk::style theme names
clam alt default classic
% exit
$

screenshot of terminal wish commands

So now you know you have the clam theme installed and so that's why this will work:

echo '*TkTheme: clam' | xrdb -merge -

This is what I get:

gitk clam screenshot

As per this answer we can improve this by setting fonts. For Pop OS we have some nice default fonts installed which we can set with the following:

  • Main font: Fira Sans Book 10
  • Diff display font: Fira Mono Regular 11
  • User interface font: Fira Sans Book 10

Note: I couldn't set the Fira Sans Book through the UI (only Fira Sans that is bold), but I could edit ~/.config/git/gitk and set:

set mainfont {{Fira Sans Book} 10}
set textfont {{Fira Mono} 11}
set uifont {{Fira Sans Book} 10}

gitk font settings screenshot

Going deeper...

However there are lots of themes listed on the tcl wiki beyond the clam theme - the screenshots at the bottom of the wiki page are very useful. They are also nicely laid out in ttkthemes on GitHub.

Its probably best that you just read the How to Install External TK Theme on the same blog post, but I'll try and explain here what I did at a later date.

Specifically I want to install the Ubuntu yaru theme which has the equivalent yaru tk theme because that will match the Ubuntu UI the best I think.

So I want the yaru theme, from ttkthemes:

# make somewhere for the theme to go
mkdir ~/.local/share/th-themes
# I'll clone into the home directory
cd ~
# only clone the latest version
git clone --depth 1 [email protected]:TkinterEP/ttkthemes.git
# yaru lives in the png set of themes
cd ttkthemes/ttkthemes/png/
# copy recursively the tcl file and the png images
cp -r yaru ~/.local/share/tk-themes
# move into the copied yaru theme
cd ~/.local/share/tk-themes/yaru
# create and edit a package index file with your favourite editor ;)
nvim pkgIndex.tcl

In pkgIndex.tcl put:

package ifneeded ttk::theme::yaru 1.2 [list source [file join $dir yaru.tcl]]

The version needs to match what is in yaru.tcl. If you're using another theme refer to that in your pkgIndex.tcl.

Then you need to add the following to ~/.profile:

# TK Themes
export TCLLIBPATH=$HOME/.local/share/tk-themes

Now at this point I started having problems. In theory a source ~/.profile should be enough, but nothing I tried worked after this until I logged-out and logged back in again.

So log out and back in...

Double check that you have set TCLLIBPATH in your ~/.profile and that it's pointing to the correct directory and you don't have a .bash_profile which will cause the ~/.profile file to be ignored.

Now with that all correct you should be able to run:

echo '*TkTheme: yaru' | xrdb -merge -

This sets and initialises your theme. Once you have done that you should be able to check again in wish that you have the yaru theme loaded:

wish
% ttk::style theme names
yaru clam alt default classic

Now finally if you open gitk you should have something prettier:

screenshot of gitk with yaru theme

You can compare this to the Pop OS settings screen:

pop os settings screenshot

Now colours and fonts for the editor, the font is too bold and the colours are ugly.

  • Fonts: I have quite a few fonts installed (Source Code Pro, Anonymous, Fira Mono etc) but lots of them just look ugly when used in gitk. Comparing gitk to gitg and GitHub desktop, what I noticed is that the fonts for them are thinner, so I went in search of a thin font. I'm currently a massive fan of Iosevka because it works everywhere (my main problem being vim powerline in gnome-terminal).
    • Its a bit difficult to understand which Iosevka font to install because there are so many, but I settled for the TTC files (all 3 base, term and fixed)

    • They're all nicely listed in each realease

    • Go there and download the TTC fonts

    • extract the zip files

    • copy them to ~/.local/share/fonts/

    • run sudo fc-cache

    • Then do yourself a favour and also to check the font is installed, restart your terminal and set the font to Iosevka (any should work but try Iosevka Terminal if you have problems)

    • Now the problem in gitk is that you can set the 'Iosevka' font, but not the light one (same as with Fira Sans), so you need to edit the config manually and use

      set textfont {{Iosevka Light} 11}

  • Colours: here's a config that I took from colorifik gitk theme and combined it with GitHub light green / light red background diff colours:
set mainfont {{Fira Sans Book} 10}
set textfont {{Iosevka Light} 11}
set uifont {{Fira Sans Book} 10}
set uicolor #f5f6f7
set want_ttk 1
set bgcolor #ffffff
set fgcolor #5c616c
set uifgcolor #5c616c
set uifgdisabledcolor #d3dae3
set colors {#00d96f #e34f4c #73c2e6 #ff79c6 #f8f8f8 #ffb86c #ffb86c}
set diffcolors {{#5c616c} #5c616c #73c2e6}
set mergecolors {#e34f4c #73c2e6 #00d96f #73c2e6 #ffb86c #8be9fd #ff79c6 #f1fa8c #8be9fd #ff79c6 #8be9fd #ffb86c #8be9fd #00d96f #ffb86c #ff79c6}
set markbgcolor #ffffff
set selectbgcolor #e7e8eb
set foundbgcolor #f1fa8c
set currentsearchhitbgcolor #ffb86c
set headbgcolor #00d96f
set headfgcolor black
set headoutlinecolor #5c616c
set remotebgcolor #ffb86c
set tagbgcolor #f1fa8c
set tagfgcolor black
set tagoutlinecolor #5c616c
set reflinecolor #5c616c
set filesepbgcolor #f5f6f7
set filesepfgcolor #5c616c
set linehoverbgcolor #f1fa8c
set linehoverfgcolor black
set linehoveroutlinecolor #5c616c
set mainheadcirclecolor #f1fa8c
set workingfilescirclecolor #e34f4c
set indexcirclecolor #00d96f
set circlecolors {#ffffff #73c2e6 #f5f6f7 #73c2e6 #73c2e6}
set linkfgcolor #73c2e6
set circleoutlinecolor #f5f6f7
set diffbgcolors {{#ffd7d5} #e6ffec}

Now we get:

screenshot with colorific colours

Now lets compare this with gitg:

side by side gitg gitk

This for me is good enough, it feels like it belongs which was my aim. I'm still very happy using gitk and I feel no desire to move to gitg, Git Kraken, VS Code, Sourcetree or any of those.

I definitely prefer gitk over the regular git log (even with making that prettier).

TODO: The branch colours can be improved.

2
  • Great answer! You could also simply configure all ttk apps to use whatever theme you want to use without app specific tweaks. The magic is environment variable TCLLIBPATH containing at least one of the themes from wiki.tcl-lang.org/page/List+of+ttk+Themes and using *TkTheme: theNameOfTheThemeYouWant. Aug 18, 2023 at 12:05
  • Thanks :) I do mention TCLLIBPATH - it's kind of buried in the middle.
    – icc97
    Aug 18, 2023 at 20:30
0

I have built tile-gtk (on Mint 17.2) with following commands:

sudo apt install tcl-dev tk-dev glib2.0-dev libglib2.0-dev
git clone git://git.code.sf.net/p/tktable/tile-gtk tktable-tile-gtk
cd tktable-tile-gtk
./configure --with-glib-lib-inc=$(pkg-config --cflags glib-2.0) --with-gtk-lib-inc=$(pkg-config --cflags gdk-2.0)
make
sudo make install
echo '*TkTheme: tilegtk' | xrdb -merge -

Works good, looks good; unfortunately I can run only one instance of gitk at time due to tilegtk.

0

After some of the suggestions here and elsewhere, I came to the conclusion this whole Tcl/Tk business is an helpless case - it never manages to use the DE theme.

Therefore I decided to try other GUIs for Git. The Git Wiki lists a number of GUIs, some of which are quite able:

  • git-cola - based on PyQt4 and seems to be most powerful in term of functionality.

  • QGit - based on Qt, looks great but lacks some functionality, especially in what concerns branches.

  • GitKraken - a powerful and elegant interface based on Electron and loaded with features; free, but requires user registration with the vendor.

My advice for users struggling with git-gui/gitk is to simply switch to one of the above.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .