Treats from git's contrib tools🍭
Tyler Cipriani Posted

The intention is to keep interesting tools around git here, maybe even experimental ones

Junio C Hamano, git/contrib/README

Git’s source repo includes a “contrib” directory containing tools that extend git.

But these tools are hidden from most users. And they require extra steps to install. So they’re less well-known than they should be.

These are the tools I’ve found useful.

diff-highlight

diff-highlight makes git diff easier to read, making subtle changes stand out.

Standard git diff (top) vs. diff-highlight (bottom)

Git diff-highlight’s author described it as “a simple and stupid script for highlighting differing parts of lines in a unified diff.”

Try it out with:

git log -p --color | /usr/share/doc/git/contrib/diff-highlight/diff-highlight

If you like what you see, make it your pager with this oneliner:

git config --global core.pager '/usr/share/doc/git/contrib/diff-highlight/diff-highlight | less'

git-prompt.sh

git-prompt.sh makes information from git status accessible at a glance.

For the basics, it’s easy1:

  1. Source git-prompt.sh from your shell init file.
  2. Add the magic incantation somewhere in your prompt (e.g., PS1='\u@\h $(__git_ps1 " (%s)")\$ ').
  3. Tweak with environment variables until you get a prompt that works for you.

Here’s my config:

GIT_PS1_SHOWUNTRACKEDFILES=1
GIT_PS1_SHOWDIRTYSTATE=1
GIT_PS1_SHOWUPSTREAM="auto verbose"
. ~/bin/git-prompt.sh
PS1='\u@\h $(__git_ps1 " (%s)")\$ '

Inside a repo on main in a clean worktree, this shows:

me@💻 (main|u=)$

If you make a big mess, the prompt makes it impossible to miss:

me@💻  (main *+%|u+1-1)$
         │   │││ │ │ │
         │   │││ │ │ └── count: changes behind upstream (-1)
         │   │││ │ └──── count: changes ahead of upstream (+1)
         │   │││ └────── indicator: upstream set (u)
         │   ││└──────── indicator: untracked file (%)
         │   │└───────── indicator: staged, uncommitted change indicator (+)
         │   └────────── indicator: unstaged change (*)
         └────────────── info: current branch name

A git-aware shell prompt solves a multitude of woes. My prompt has saved me from countless sticky git situations.

subtree

git submodule allows you to include other git repos within your repo. But anyone who’s used it can tell you: it gets confusing fast.

git subtree eases git submodule pain.

Both submodule and subtree let you add a library as a subfolder of your project.

But subtree integrates the history of the library into your main project. And you can get it back out as a standalone library later.

This lets you branch and tag a project along with its libraries—a critical limitation to git submodule.

For example:

git clone https://github.com/thcipriani/my-parent && cd my-parent
git subtree add --prefix=mylib https://github.com/thcipriani/my-library

Adds my-library to the my-parent project in a folder called mylib—the two projects’ history gets merged. From there, it works like a monorepo.

After I’ve made a series of changes inside my-parent, including changes to mylib, I can extract the history of mylib with:

git subtree split --prefix=mylib
0b64183b7a0a27ad1f466d5cac61cbfefd1e598e
git push https://github.com/thcipriani/my-library 0b64183b7a0a27ad1f466d5cac61cbfefd1e598e:master

Or, in one step:

git subtree push --prefix=mylib https://github.com/thcipriani/my-library main

More

  • git worktree: is an example of a contrib script that’s made the jump to a git built-in command. Maybe, in time, other commands in this list will, too.
  • git-jump: opens your editor to interesting bits of code. For example, git jump diff opens vim to the first diff hunk.
  • mw-to-git: lets you read and edit MediaWiki wikis (like Wikipedia) as if they were a local git repo (cf: maintaining userscripts with git)
  • pre-auto-gc-battery: a hook that prevents git’s automatic garbage collection if you’re on a laptop using battery power

And there are even more weird gems to unearth. Take a look!


  1. The script contains detail usage instuctions, too↩︎

Framework DIY 13 AMD review ⚙️
Tyler Cipriani Posted
Framework Laptop DIY 13 AMD with ethernet dongle and screwdriver

The laptop industry is a tragedy.

Meanwhile, Framework built something different—repairable, Linux-ready laptops that respect users. Framework is a rare company worth your support.1

So, this month, I bought their 13.5″, AMD-powered laptop—the Framework 13 AMD.

But I’ve seen mixed reviews from other Linux users. I like the Framework ethos—I hope I like their laptops, too.

🛠️ DIY Hardware and assembly

Framework offers two editions of its laptops:

  1. Pre-built – Fully assembled, complete with a useless (to me) Windows™ install.
  2. DIY – Do it yourself (DIY). Some assembly required—BYO-OS.

I opted for the DIY edition—a misnomer, given assembly took five minutes.

Framework DIY—little assembly required (NVMe, RAM, keyboard, bezel: that’s it)
  • CPU 8-core/16-thread 5.1Gz AMD (AMD Ryzen™ 7 7840U)
    • AMD Radeon 780M integrated GPU (works fine with amdgpu driver)
    • Ryzen AI Neural Processing Unit (NPU) (AMD released an xdna driver last week. I have yet to try it.)
  • 64 GB RAM – DDR5-5600
  • 2TB NVMe
  • 13.5” (diagonal) matte (🥳) screen

This is a powerful machine.

🏋️ Weight

Framework 13 weighing in at 1,323Kg, about the same as the 2011 Macbook Air

A notebook that weighs more than a kilo is simply not a good thing

Linus Torvalds

The Framework weighs more than a kilo.

Fully assembled (stickers and all), my new laptop tips the scales at 1,323g.

It’s 100g lighter than my x220 but 100g heavier than my partner’s M2 Macbook Air.

The Framework weighs as much as the 2011 Macbook Air—a sure sign innovation has stopped in this space.

🔌 Ports/dongles

Ports on the ThinkPad vs Framework—sadly absent: PCMCIA card slot

I’m torn.

I can arrange my laptop’s USB, power, and ethernet ports however I want them.

And folks in the Framework community are cooking up new ideas.

But these are dongles. Brilliant dongles, but dongles nonetheless—I have to tote them on my travels and keep track of them all.

A dongle by any other name…

Now, I need a little pouch for my adorable dongles.

🪫 Battery life

Folks flagged short battery life as a problem for these machines—especially the Intel version. Is that true for the AMD version?

To test this, I simulated some strenuous web surfing—clicking Wikipedia links faster than is humanly possible.2

Results:

Time to battery empty Brightness Delay between page clicks Avg CPU Percentage Avg Watts
02:20:21 100% 0s 13.8% 23.4
02:55:07 0% 0s 13.8% 19.8
12:57:57 😅 0% 10s 1.1% 4.1

As long as I’m not slamming through every page of Wikipedia, the battery would get me through most work days.

During the workday, I use between 5 and 10 watts.3 While that might not give me 13 hours, it beats my ThinkPad X220’s 1.5-hour battery life.

Linux setup

Linux veterans relayed painful experiences running their OS on older Framework models.

But my experience was (mostly) jank-free.

Ubuntu 22.04

I installed Ubuntu first, since it’s the sole Linux distribution Framework’s website listed as “Stable.”

And Ubuntu 22.04 ran flawlessly.

Chalk this up to the detailed Framework Ubuntu setup guide, with its giant gob of copy-pasta commands—much laudable, painstaking effort has gone into making this experience perfect.

Debian Bookworm

I perused the Debian Wiki’s Framework pages and the Debian Install Guide as references to install Debian Bookworm.

Audio, wifi, bluetooth, touchpad, webcam, and every button worked out of the box.

Then I closed the lid, but nothing happened. Sleep failed.

Problems with s2idle on AMD machines are common. Problems are so common that Freedesktop cobbled together a script with cute emojis to help troubleshoot: amd_s2idle.py.

Framework user forums pointed me to the firmware-amd-graphics Debian package bug 1053856.

After firmware fiddling and an hour+ tweaking Xmonad for the high-dpi (2256x1504) display: all’s well.

I hate computers, but this one is pretty good.

@FramworkPuter, 2024-01-19

What I like:

  • Repairable – I hoard a closet of old ThinkPads because I know they’ll end up at the dump otherwise.
  • Hardware camera/mic switch + RFKill – Hardware switches beat camera covers any day. And a laptop that respects its users’ privacy is lovely.
  • Reference designs – While it’s not open hardware, Framework releases reference designs under a Creative Commons license.
  • Matte screen – Why are shiny screens an option? Who wants that?

What I dislike:

  • Keyboard – It’s mushy. Plus, the button under [/?] is [←], which is breaking my brain. I’m used to it being right CTRL (which I use as AltGr).
  • Brightness – Even at 0% brightness, the screen is too bright. There’s probably something I can do here.
  • HDMI requires back slots – HDMI expansion card plugged into the front left expansion slot failed. Moving to one of the back slots works.
  • 3:2 aspect ratio – Why? It’s an outre choice. I’m having a bad time mirroring to 16:9 displays. Plus, horizontal screen space is great for tiling window managers.
  • Trackpad – I still like buttons. The trackpad is good, but I’m a luddite—ThinkPads spoil you.
  • Keyboard backlight – Speaking of ThinkPads, why have we abandoned the ThinkLight?

🏛️ Verdict

In a barren industry where planned obsolescence is the norm, Framework produces nice hardware for a fair price.

The Framework AMD 13 is a powerful, modern laptop capable of running Linux. And all the buttons seem to do what they’re supposed to.

I look forward to the day when I can Ship-of-Theseus the guts of this beast to get an even beefier boxen. It sure beats throwing it on the pile of ThinkPads collecting dust in my closet.


EDIT 2024-01-31T13:53:30-07:00: Before, this article referred to the Framework AMD 13 as the “13th generation.” Commentors pointed out that that was incorrect. The 13th generation Framework laptops refer to the 13th generation of the Intel CPUs, not the Framework hardware.


  1. Man, I hope this comment ages well.↩︎

  2. I scripted the “Getting to Philosophy” Wikipedia game for the top 400 Wikipedia Articles of 2023↩︎

  3. Unless I do something silly like attend a zoom meeting.↩︎

Jan 2024
S M T W T F S