hardscrabble 🍫

By Max Jacobson

Psst. Check out bluff.website, a game I made, for you to play with your friends on your zoom calls.

git cleanup-branches

01 Mar 2018

Do you clean up your git branches as you go or are you, like I am, a lazy hoarder?

$ git branch | wc -l

Look at all those things I did that I don’t care about anymore.

Yesterday I googled a little to try and find some magic incantation that would just clean up my branches for me. There are some, but I find that they’re either too conservative or too liberal for me. By “too conservative” I mean that they try to only delete branches that have been merged, except that they’re not actually very accurate, because they aren’t aware of GitHub’s “Squash and Merge” or “Rebase and Merge”, which I use pretty much exclusively. By “too liberal” I mean that some people recommend just literally deleting all of your branches.

I want to have control over the situation.

I can just run git branch -D branch-name-goes-here over and over, one-by-one, for all of my branches, but that would take several minutes, which I definitely technically have, but don’t want to spend that way, even while curled up with a podcast.

What I really kind of want is some kind of interactive process that gives me total control but doesn’t take that long to do. So I made a little shell script, which looks like this to use:

gif demonstrating git cleanup-branches which lets you interactively delete branches

As you may notice, it takes some loose inspiration from git’s interactive rebase.

It does something like this:

  1. get your list of branches
  2. open your default editor (whatever you have the $EDITOR global variable set to) (vim for me)
  3. wait for you to mark which branches should be deleted
  4. delete the ones you marked

git lets you plug in little scripts by just naming them git-whatever-you-want and putting that script on your $PATH and I think it’s fun to take advantage of that.

Here’s the latest version of the script as of this writing:

#!/usr/bin/env bash

set -euo pipefail


function removeCurrentBranch {
  sed -E '/\*/d'

function leftTrim {
  sed -E 's/\*?[[:space:]]+//'

all_branches=$(git branch | removeCurrentBranch | leftTrim)

# write branches to file
for branch in $all_branches; do
  echo "keep $branch" >> $file

# write instructions to file
echo "

# All of your branches are listed above
# (except for the current branch, which you can't delete)
# change keep to d to delete the branch
# all other lines are ignored" >> $file

# prompt user to edit file
$EDITOR "$file"

# check each line of the file
cat $file | while read -r line; do

  # if the line starts with "d "
  if echo $line | grep --extended-regexp "^d " > /dev/null; then
    # delete the branch
    branch=$(echo $line | sed -E 's/^d //')

    git branch -D $branch

# clean up
rm $file

It follows the “chainable shell function” pattern I’ve written about before.

It uses set -o pipefail, my favorite recent discovery in shell scripting, which makes sure that each command succeeds, not just each expression. I should probably do a separate blog post about that with more detail.

Yeah, I guess that’s pretty much it. Have fun shell scripting out there.

2017 in television

03 Jan 2018

Here’s my favorite shows that aired in 2017. Just sharing because I spent way too much time this year watching television, so maybe this will help you pick the good stuff, as long as your taste is also my taste, which it’s not. I’ll try to avoid spoilers.

10. Mr. Robot (s3)

This show remains a technical wonder. It has a very sharply drawn aesthetic – you know you’re watching this show by the mannered acting and the off-center camera compositions more than anything else. Nothing I saw on television was as cool as the 4th episode, which is presented as one long take, and aired without commercials. It feels like the rules don’t apply to this show. This season was mostly about pain and regret and what to do with them. Anything productive? Maybe it’s possible.

Rami Malek is and has been great, but this season was as much about the constellation of characters around him. This show knows it’s fun to watch smart people do hard things and so it drew up a bunch of them, made you love or fear them, and set them against each other. I particularly liked any scene with Dom, Grant, Darlene, or Angela.

Highlight: eps3.4_runtime-error.r00

9. Crazy Ex-Girlfriend (part of s2 / part of s3)

I’ve loved Rachel Bloom since I Steal Pets, a truly brilliant, stupid music video she made in 2011. Somehow she’s made a show that has several hysterical songs in each episode, a cast of lovable gentle Californian weirdos, and a very thoughtful depiction of what it’s like to struggle with mental health. It really feels like an auteur work in the sense that it’s hugely personal and no one else could’ve or would’ve made it. She writes and acts and sings. It’s nuts. I giggled like a child all through “I Go To The Zoo” and “The First Penis I Saw” and felt a swell of an uneasy hope during “My Diagnosis”.

Highlight: Josh Is A Liar

8. Catastrophe (s3)

This show is mostly special beacuse it’s very funny, and there are few pleasures comparable to Sharon and Rob making fun of each other so cruelly that you know they must really love each other or how else could they put up with that? It’s also one of the best, most real-feeling stories of alcoholism that I’ve seen. It reminded me, at times, of a crime drama like Dexter where the anti-hero has a secret and we’re for some reason invested in him not being found out as a serial killer, except here he’s sneaking drinks, and you feel it in the pit of your stomach that this is bad. It’s mostly very funny. But it’s also very dedicated to arguing that we’re better when we step up and be there for each other even when it sucks and I find that helpful to think about. The drama is very ordinary but the characters are so lovable that you care. And Carrie Fisher is great.

Highlight: Episode 6

7. The Marvelous Mrs. Maisel (s1)

Just watched this one over Christmas break, with my mom, so there may be some recency bias here, but I really loved it. This show entertains on so many levels. It’s hysterical, with great characters, acting, and dialogue. The scenes between the comedian characters in particular feel funny in a way that funny people are with each other, where they want to skip past the norms of what they’re supposed to say, and then also not laugh, and then also act like that was normal. All the scenes with Midge and Lenny Bruce were golden like that. And just watching a show about a person figuring out they want to do some kind of art and that they might be good at it and then realizing it’s going to be a lot of work and maybe not that fun all the time is hugely fun, because each step feels real and earned and satisfying. That that person is a Jewish woman with two kids in the fifties in Manhattan played by someone as charismatic as Rachel Brosnahan makes it feel very unique and alive. Also her parents are hysterical and Joel sucks in such a real and lived in way that it almost brings pleasure how reliably the dude sucks. And that the cinematography is frequently dazzling, with a camera that floats through clubs and apartments and over tables and around Hora dancers, and the soundtrack crackles with sometimes on-the-nose but very charming contemporary songs makes the whole thing just kinda whizz by.

Highlight: Because You Left

6. The Americans (s5)

Maybe I’m a sucker and a fool for things that are just the slightest bit unusual, but the premier’s exhuming sequence, which has no dialog for something like 15 minutes as we just watch these people do their job ultra competently and feel the weight of it on their backs and the amount they’re stuck with the decisions they’ve made and have been made for them growing and growing … is very good … and is enough to make me sit up straight and hold my breath.

This is the penultimate season and it kinda feels like one. This is the TV show version of a clenched jaw. It’s all heading to hell, for sure. I think of it as a show about marriage and parenting, which isn’t really an original way to think about it. But it really makes me feel the painful feeling that maybe for all our/their hard work, the next generation won’t really be better off. On that theme, the new characters of Tuan and Pasha were fascinating and painful to watch.

Highlight: Amber Waves

5. The Leftovers (s3)

The final season! This show was based on a book, but they pretty much covered it in the (pretty good) season one. Seasons two and three veered off and did their own thing and explored grief, mental health, love, religion, and family using some of the most bizarre scenarios with the most committed cast. It’s a really stunning show just to look at even if you don’t have any idea what’s going on, which you mostly don’t. Justin Theroux and Carrie Coon are incredible.

I don’t really need things to stick the landing perfectly; Lost’s ending wasn’t perfect but it was fine IMO. The Leftover’s is another Lindelof joint, and it does feel like Lost is hanging over it a little. He did a better job of managing expectations this time, because I don’t think anyone watching expected the show to start making sense right at the end. Nevertheless, the ending had me spellbound.

Highlight: It’s a Matt, Matt, Matt, Matt World

(for the submarine sequence if nothing else, but also the rest)

4. Better Call Saul (s4)

I did like Breaking Bad a lot and I didn’t really know what to make of this when it started. It’s a little hard to talk about. It’s really its own show, distinct from Breaking Bad. When I say that the whole show was building to this season, that doesn’t mean what you think it means if all you know is it’s the Breaking Bad prequel show. More than that it’s a family drama about a handful of lawyers, all proud, all brilliant, each kind of broken in their own way. Like Breaking Bad, it’s about how people’s consciences rot and fall away, or don’t, and the effects on other people. It’s pretty heavy, but in a way that feels real and awful. It’s also, frequently, hysterical.

Highlight: Lantern

3. The Carmichael Show (s3)

Really sharp writing and amazing chemistry from the cast. Nothing else made me laugh as often. I loved the sneaky emotional ones, too, which is almost all of them. Each character gets to take their turn being the asshole taking the overly harsh position on whatever the argument of the week is, and actually gets a chance to speak their mind, and then they keep digging until they find some understanding. It’s a very winning formula. I’m sad this one ended.

Highlight: Cynthia’s Birthday

2. Nathan For You (s3)

Nathan For You is audacious and radical and sweet and kind of cruel and depressing. I hope he does more. It’s so unpredictable, but in unpredictable ways. Most of the funniest moments come from Nathan violating some social norm, but the surprising thing is how polite he is as he does it. I often feel terrible for his subjects, except that it’s very hard to find fault in Nathan’s behavior. He’s never really ridiculing anyone. He’s more enabling people to succeed at whatever their dreams are, if only temporarily. That their results are uniformly terrible makes their dreams feel small and unimportant and them seem foolish for even having them. But maybe it’s better to live your dream than to not?

Highlight: Finding Frances

1. Halt and Catch Fire (s4)

This was the fourth and final season and it was just about perfect. The episode called “Goodwill” is one of the most beautiful things I’ve ever seen on television. What this show did better than any other is make you really love its characters and care about them and feel for them. That it was about the early days of the internet and felt real and lovely is only extra credit. That it told the story of Cam and Donna struggling and having success as women in tech, also extra credit, and I think not talked about enough, IMO.

Highlight: Goodwill

Honorable mentions (alphabetical ordered)

  • Black Mirror (s4)
  • Bold Type, The (s1)
  • Brooklyn Nine-Nine (s5)
  • Fargo (s3)
  • Fresh Off the Boat (s4)
  • Girls (s6)
  • Good Place, The (s2)
  • Master of None (s2)
  • Mindy Project, The (s6)
  • Scandal (s7)
  • Search Party (s2)
  • Sweet/Vicious (s1)

Also enjoyed (alphabetical ordered)

  • Broad City (s4)
  • Curb Your Enthusiasm (s9)
  • Game of Thrones (s7)
  • Glow (s1)
  • Handmaid’s Tale, The (s1)
  • Legion (s1)
  • New Girl (s6)
  • Rick and Morty (s3)
  • Stranger Things (s2)
  • Unbreakable Kimmy Schmidt (s3)
  • Veep (s6)
  • You’re the Worst (s4)