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:
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
$
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:
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}
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:
You can compare this to the Pop OS settings screen:
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:
Now lets compare this with gitg:
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.
gitg
is too slow - I've done my best to make gitk fit into Ubuntu in 2022: superuser.com/a/1707378/41494