<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="4.3.3">Jekyll</generator><link href="https://5xx.engineer/feed.xml" rel="self" type="application/atom+xml" /><link href="https://5xx.engineer/" rel="alternate" type="text/html" /><updated>2026-02-14T16:51:29-05:00</updated><id>https://5xx.engineer/feed.xml</id><title type="html">5xx.engineer</title><subtitle>A blog about myself</subtitle><author><name>Collin</name><email>collin@5xx.engineer</email></author><entry><title type="html">Reviewer First Pull Requests</title><link href="https://5xx.engineer/2025/02/13/rfprs.html" rel="alternate" type="text/html" title="Reviewer First Pull Requests" /><published>2025-02-13T00:00:00-05:00</published><updated>2025-02-13T00:00:00-05:00</updated><id>https://5xx.engineer/2025/02/13/rfprs</id><content type="html" xml:base="https://5xx.engineer/2025/02/13/rfprs.html"><![CDATA[<p>Pull requests continue to be the primary mechanism by which we collaborate and contribute code.
Despite this we often will put as little effort as possible into creating PRs. I’d like to convince
you that even a small investment in improving them pays over-sized dividends to the project and your
team members.</p>

<h1 id="table-of-contents">Table of Contents</h1>

<ul>
  <li><a href="#background">Background</a></li>
  <li><a href="#reviewer-first-pull-requests-rfprs-overview">Overview</a></li>
  <li><a href="#rfpr-guidelines">Guidelines</a></li>
  <li><a href="#commits">Commits</a></li>
  <li><a href="#tooling">Tooling</a></li>
  <li><a href="#about-commit-mistakes">About Commit Mistakes</a></li>
  <li><a href="#receiving-feedback">Receiving Feedback</a></li>
  <li><a href="#merge-or-squash-merge">Merge or Squash Merge?</a></li>
  <li><a href="#appendix-commit-order-reviews">Appendix: Commit Order Reviews</a></li>
</ul>

<h1 id="background">Background</h1>

<p>I’ll start by admitting that because the PR is frequently at the very end of a development effort
that we should pay respect to the mental exhaustion present. A project spike will start with a
mountain of known unknowns, and some unknown unknowns as well, all of which an IC will be
accountable for, in addition to writing code that is maintainable, tested, and covers edge cases. It
can be exhausting and therefore understandable that we would feel the impulse to create the PR as
quickly as possible to get it over the finish line. I hope you’ll agree that by the end of this post
that spending a bit more effort to create a better PR is worth it, and is probably not as much
effort as you might think.</p>

<p>Let’s start with the perspective of the reviewer. Everyone is familiar with this scenario: you get a
notification about a new PR you need to review. You open the PR and see that the title of the PR is
a JIRA ticket. The description of the PR is blank. You find the JIRA ticket and read it to get some
context before continuing. Going back to the PR, you see about forty commits, many of which are
things like “migration” or “wtf please work” or worse. Given this you click the “Files changed” tab
and see that there are 5k lines of code changed, across 30 files. Resigned to your fate, you then
try to understand this large changeset all at once. Because it’s incredibly difficult to do so and
because you are also under pressure to deliver your own changesets, you end up reviewing it at the
surface level, leaving style feedback and perhaps some more nuanced commentary for the parts you are
able to understand more easily.</p>

<blockquote>
  <p>This is clearly not the experience we want.</p>
</blockquote>

<p>As the creator of the PR, you are hoping to merge it. But past that, you also want your teammates to
let you know of things that you may not have considered, or why this particular algorithm you’ve
employed may have negative effects on the backend APIs it eventually calls. Style nits are OK but
avoiding an incident by pointing out an unhandled edge case is much better.</p>

<p>The reviewers only have so much time to devote to your PR. If that time is largely spent being
mystified about the changeset, that is time that they are not spending giving you the quality
feedback you should be hoping for. The time a reviewer spends on any particular PR is then
multiplied by the number of people that end up reviewing it.</p>

<p>The value of a well documented PR lives on past just the initial review, too. If this is a service
running in production, someone else on-call that didn’t review the PR may need to refer back to it
when there’s an outage and they are trying to understand what happened. If this is an OSS project,
people may want to review the PRs that land in the next release to better understand how the project
is changing.</p>

<blockquote>
  <p>Time spent creating a better PR pays dividends many times over.</p>
</blockquote>

<h1 id="reviewer-first-pull-requests-rfprs-overview">Reviewer First Pull Requests (RFPRs) Overview</h1>

<p>Reviewer First Pull Requests (RFPRs) are a prescriptive approach to building better PRs that are
easier to review. One time at Mesosphere after I pushed a PR that was hard to review, <a href="https://www.linkedin.com/in/klueska">Kevin
Klues</a> introduced me to his “Reviewer-First” methodology and
I’ve been promoting it ever since.</p>

<blockquote>
  <p>At the heart of RFPRs is the concept that PRs, like a book, should tell a story.</p>
</blockquote>

<p>When reading a book, you typically know what it’s about before you start because you’ve read the
intro on the back. You start at the first chapter, and continue reading until the end. Even if the
book was particularly long or complex, the chapters were structured in a way to guide you through
the story that the author wanted to tell.</p>

<p>RFPRs operate under the same principle. A reviewer should be able to open the PR and read the
description to get a good idea for what the PR is addressing and what to expect inside. RFPRs are
structured so that they can be reviewed commit-by-commit, in order, leaving feedback as they go.</p>

<blockquote>
  <p>Large or complex PRs are made more approachable if the author guides the reviewers.</p>
</blockquote>

<h1 id="rfpr-guidelines">RFPR Guidelines</h1>

<p>Following are guidelines for creating RFPRs. Afterwards we’ll discuss some tooling that will make
following the guidelines much easier.</p>

<h2 id="pr-titles">PR titles</h2>

<p>PR titles should describe what the PR accomplishes.</p>

<p>Examples of good PR titles:</p>

<ul>
  <li>[CONTROL_42] Expose gRPC endpoints for all controlplane APIs.</li>
  <li>kafka: Create new topic for user events and enable mirrormaker for all regions.</li>
  <li>Modify CMS domain models to use composition instead of inheritance.</li>
</ul>

<p>PR titles which should be avoided:</p>

<ul>
  <li>[CONTROL_42] (just a JIRA ticket number)</li>
  <li>fix bug</li>
  <li>(nothing)</li>
</ul>

<p>Imagine that you are trying to find a particular PR on GitHub during an incident. The PR title
should be descriptive enough so that it can be easily identified.</p>

<h2 id="pr-descriptions">PR descriptions</h2>

<p>The PR description sets the stage for the reviewer. Since they are going to review the PR
commit-by-commit, the description should give them as much context as possible before they start.
Assume that the reviewer does not have the context that you do.</p>

<p>The description should roughly include these components:</p>

<ol>
  <li>Links to tickets or other prior art.</li>
  <li>Overview of the problem or business goal.</li>
  <li>Description of your approach.</li>
  <li>Callouts to any parts which are complex or about which you are hoping for extra feedback.</li>
  <li>Edge cases and risks.</li>
</ol>

<p>It’s worth noting that PRs which are small in scope will have a correspondingly smaller PR
description. PRs which are large or complex will have a larger PR description. This is largely
subjective, and at first I think it might feel like it’s unnecessary work, but that is temporary. In
fact I’ve found that by writing a detailed description, I will sometimes remember things I had
forgotten to address during development. By writing the description <em>for the reviewer</em> this causes
you to think about the things that the reviewer would probably have questions about. Anything you
catch at this phase is a major win, as it is a short amount of time compared to the revisions to the
PR which would otherwise follow.</p>

<p>Code snippets (for example, to showcase a new interface you are adding) are often really helpful in
the description.</p>

<h2 id="commits">Commits</h2>

<p>The reviewer should expect to be able to <a href="#CommitOrderReviews">review your PR in commit order</a> if
they choose. What order should the commits be in and what should the commits contain? Remember that
we are assuming that the reviewer is coming in fresh and probably does not have the familiarity with
the code that you do.</p>

<p>In general I try to isolate what I consider to be “high value” and “low value” changes in separate
commits. A high value commit would be something like adding a new trait, or implementing that
trait for a number of domain models. Low value commits would be things like formatting, or code
imports. To make it as easy as possible on the reviewer, allow them to briefly consider low value
changes and spend more time on the high value changes.</p>

<blockquote>
  <p>Do not mix high value and low value changes in the same commits.</p>
</blockquote>

<p>Since the reviewer is reading in commit order, we should also strive to limit the scope of any
particular commit. If your PR is adding and implementing five interfaces to all of the domain
models, a reasonable approach would be to have each interface, and the implementation of that
interface, be in its own commit. If you’re sweating now because you’re not comfortable with Git,
don’t worry – we’ll talk later about tools you can use to build these kinds of commits.</p>

<p>Guidelines for good commits:</p>

<ol>
  <li>Commits should be limited in scope.</li>
  <li>Do not mix high value and low value concerns in the same commit.</li>
  <li>Commit titles should be a full sentence that describes an action.</li>
  <li>Commit descriptions should discuss that commit’s changes as necessary.</li>
</ol>

<p>Here’s an example of a medium-sized PR that follows these guidelines:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>Set ECS Attribute to indicate health of ledger latency

JIRA: F8N-365

# Overview

This is the first step of a longer term goal to be able to control the behavior of ECS task
placement for tasks which rely on this database. The idea is that if the task requires a healthy
ledger latency we can avoid placing it on a node which is behind.

# Approach

This PR adds some new behavior to the reflectors. The reflectors will start a ledger latency
monitor when they start. This monitor will periodically look at the ledger latency as reported
by the db client. If below a max threshold, it will ensure that the container instance on which
it runs has an ECS attribute to indicate the ledger has fallen behind.

# Next Steps

After this is deployed and working we should spot check new instances to ensure that they are
not marked as 'healthy' if they are still working on updating the ledger. Once we are confident
in this, we can then update our deployment tooling to lean on this new attribute.
</code></pre></div></div>

<p>The commits on this PR try to follow RFPR guidelines. Notice how low value and high value changes
are isolated:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>* Move loop helper code to pkg/loop.
* Add ECS dependencies.
* Update executive interface mock.
* Create an ECSClient interface and generate mock.
* Create EcsMetada type to unmarshal ECS metadata.
* Create ledger monitor to set ECS 'unhealthy' attribute when falling behind.
* Add functional options for the Monitor.
* Update reflector config to also compose ledger health config.
* Add tests to verify attribute is set correctly using a mocked ECS environment.
</code></pre></div></div>

<p>Example of what I consider to be a reasonable commit within this PR.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>Create ledger monitor to set ECS 'unhealthy' attribute when falling behind.

The monitor follows the pattern that the other types use, where a Start(ctx) method blocks, and
only exits when the context is canceled.

It follows this high level logic:

* Every time the *time.Ticker ticks:
    * get the ledger latency from the db
    * compare this value to threshold
    * if latency is OK, set a 'healthy' attr
    * else set 'unhealthy' attr

It keepds the last known successful ECS attr set in a local var so that it doesn't set the attr
on each tick. The variable is a *bool because we need three states:

1. unknown state of ECS attr
2. 'healthy'
3. 'unhealthy'
</code></pre></div></div>

<p>These are the kinds of PRs I’m thankful to get notified about. I might spend on average 15-30m extra
to create PRs using these guidelines, but it saves many hours across the reviewers assigned to it,
and the quality of feedback you get on your RFPR will invariably be higher.</p>

<h1 id="tooling">Tooling</h1>

<p>Much of RFPRs ends up being a writing exercise – writing your PR title, PR description, commit
titles, commit descriptions, with the reviewer in mind. But a large part of RFPRs involves commit
discipline. If you’re like me, you really only know what the changeset is going to look like after
you finish making all of your changes. As I approach the finish line, my feature branch has tens if
not hundreds of garbage commits.</p>

<p>In fact I have a <code class="language-plaintext highlighter-rouge">ci</code> (checkin) script that enables these garbage commits. I love it:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c">#!/usr/bin/env bash</span>

<span class="nb">set</span> <span class="nt">-euo</span> pipefail

<span class="nv">msg</span><span class="o">=</span><span class="s2">"</span><span class="k">${</span><span class="p">*</span><span class="k">:-</span><span class="nv">wip</span><span class="k">}</span><span class="s2">"</span>
git add <span class="nt">-A</span>
git commit <span class="nt">-m</span> <span class="s2">"</span><span class="k">${</span><span class="nv">msg</span><span class="k">}</span><span class="s2">"</span>
</code></pre></div></div>

<p>I use this constantly and so my feature branch is littered with <code class="language-plaintext highlighter-rouge">wip</code> commits. These are my
breadcrumbs that enable to me to “checkpoint” my progress in a way that doesn’t take me out of the
flow. They also let me back out more granular changes – maybe I wanted to see if a particular change
made sense. I <code class="language-plaintext highlighter-rouge">ci</code> before I start, and if I hate it, it’s easy for me to throw away that change
without risk of throwing away what came before it.</p>

<p>A branch that looks like this is clearly not RFPR-ready. How then do we go from a feature branch
full of <code class="language-plaintext highlighter-rouge">wip</code> comments to something that is a RFPR? My strategy, which works for me, is to wait
until the very end to restructure my commits. The primary way I do this is by using <code class="language-plaintext highlighter-rouge">git reset</code> and
<code class="language-plaintext highlighter-rouge">lazygit</code>. Note that there are a lot of tools like this, and I encourage you to explore what is
right for you.</p>

<h2 id="git-reset">git reset</h2>

<p>Your feature branch (e.g. <code class="language-plaintext highlighter-rouge">collin/ecs-attr</code>) is meant to eventually merge into a base branch, which
is often <code class="language-plaintext highlighter-rouge">origin/main</code>. Our goal is to 1) keep all of our changes and 2) craft custom commits that
tell the story of our RFPR.</p>

<p>If you’re not familiar with <code class="language-plaintext highlighter-rouge">git reset</code>, it probably sounds scary, but it’s not actually destructive
in the way it sounds. Using <code class="language-plaintext highlighter-rouge">git reset --hard</code> IS destructive and should be used with care.<code class="language-plaintext highlighter-rouge">git
reset</code> will point your branch to whatever you reset it to, and any changes on your branch will be
moved into the working tree. The effect is that it is as-if you just created your feature branch on
top of <code class="language-plaintext highlighter-rouge">origin/main</code> and then made all of those changes. From there we can start building our
commits.</p>

<ol>
  <li>(on <code class="language-plaintext highlighter-rouge">collin/ecs-attr</code>): <code class="language-plaintext highlighter-rouge">git fetch; git merge origin/main</code></li>
  <li>(on <code class="language-plaintext highlighter-rouge">collin/ecs-attr</code>): <code class="language-plaintext highlighter-rouge">git reset origin/main</code></li>
  <li>Build commits</li>
</ol>

<p>All of our changes have now been unstaged and it is up to us to build our commits.</p>

<p>I like to start with the lightweight concerns. If you have some documentation changes, add those
files into a commit. If your feature required modifying some other things to support it, adding
commits for those updates would be reasonable. After I’m done with the prerequisites, I then add
commits for the changes which are at the heart of my PR. Following those are typically commits which
address testing. Finally, I usually save most of my formatting changes for one commit near the end
which reviewers can spend minimal time on since it should be a no-op.</p>

<p>Some commits are naturally scoped to whole files. For example, if you updated the README, then
adding the whole README file (<code class="language-plaintext highlighter-rouge">git add [file]</code>) and then making a commit is reasonable.</p>

<p>If your PR was introducing five new interfaces and implementations across your domain models, you’d
probably want each of those to be its own commit, but the model files they modify are the same ones.
You need some way to only add parts of each model file for the commit that adds one of the
interfaces. Similarly, how do you isolate formatting changes when those changes touch most of the
files? <code class="language-plaintext highlighter-rouge">lazygit</code>!</p>

<h2 id="lazygit">lazygit</h2>

<p><a href="https://github.com/jesseduffield/lazygit">Lazygit</a> is a terminal UI (TUI) that enables you to
easily perform Git actions that would otherwise be more difficult. This is a screenshot of my <code class="language-plaintext highlighter-rouge">blog</code>
repo which I use for this site:</p>

<p><img src="/assets/images/lazygit.png" alt="lazygit" /></p>

<p>It’s organized into different pages, each of which has a different responsibility:</p>

<ul>
  <li>changed files</li>
  <li>branches and remotes</li>
  <li>commit list</li>
  <li>stash</li>
  <li>changes diff</li>
</ul>

<p>Using this interface, I will frequently:</p>

<ul>
  <li>build commits for a RFPR after a <code class="language-plaintext highlighter-rouge">git reset</code> to the base branch.</li>
  <li>add individual lines across multiple files into a new or existing commit.</li>
  <li>reorder commits on a feature branch.</li>
  <li>amend a commit with a particular change.</li>
  <li>take a change out of a commit and create a new commit from it.</li>
  <li>… and much more</li>
</ul>

<p>This post does not intend to be a tutorial on how to use <code class="language-plaintext highlighter-rouge">lazygit</code>. You should start with the
<a href="https://github.com/jesseduffield/lazygit?tab=readme-ov-file#tutorials">Tutorials</a> to get a sense
for it. Getting a hang of the keybinds takes a short while, and then you can configure it to your
liking.</p>

<p>Believe me when I say that using a tool like this gives you a lot of power. So much so that when I
create a RFPR, I spend more time on writing the documentation for it than actually building the
commits using <code class="language-plaintext highlighter-rouge">lazygit</code> – it’s that good.</p>

<h2 id="about-commit-mistakes">About Commit Mistakes</h2>

<p>The above approach is really helpful in ensuring that reviewers do not spend time giving feedback
for changes that will never merge. Imagine you have a PR with 10 changes. The 5th commit introduces
a bug which is then fixed in the 8th commit. Assuming that the reviewer will be reviewing in commit
order, they will likely spend time giving feedback about the bug in the 5th commit, only to become
irritated that they spent that time unnecessarily.</p>

<p>Backing out all of your changes and then building the commits before the PR is created avoids this
problem entirely. Performing a <code class="language-plaintext highlighter-rouge">git reset</code> to <code class="language-plaintext highlighter-rouge">origin/main</code> will in effect merge your changes
together, only leaving the correct, bug-free diff.</p>

<p>If after you’ve created your commits you notice a bug in the 5th commit, you definitely do not need
to start all over. You can fix the bug in the working tree and then in <code class="language-plaintext highlighter-rouge">lazygit</code> navigate to the
commit where the bug is. Hitting <code class="language-plaintext highlighter-rouge">A</code> will amend the selected commit with your changes. There are a
lot of nice-to-haves like this in <code class="language-plaintext highlighter-rouge">lazygit</code>.</p>

<h1 id="receiving-feedback">Receiving Feedback</h1>

<p>Once you’ve posted the RFPR, gotten feedback, and need to make followup commits, those commits
should also be RFPR commits. Other people will come back later and read through them and we should
also respect their time.</p>

<p>I would highly recommend <em>not</em> rebasing or rewriting commits after you start getting feedback. The
reason for this is that reordering or amending commits ends up creating new commits under the hood
(even if <code class="language-plaintext highlighter-rouge">lazygit</code> made it super easy to do so). Because reviewers will leave feedback on each
commit during the initial review, if you rewrite that commit as a followup and force push, the
feedback they left becomes orphaned and out of context because that commit no longer exists.</p>

<p>For that reason, it’s better to push new commits when addressing feedback, even if those changes
would normally be structured differently if you were creating the RFPR from scratch.</p>

<h1 id="merge-or-squash-merge">Merge or Squash Merge?</h1>

<p>Once you’ve gotten your approvals and are ready to merge, what then about how to merge? You can
either merge normally or use a squash merge. I don’t think there’s a clear answer on this. Perhaps
we’ll get one when the tabs vs spaces debate gets settled. I’m happy though to share how I view this
decision.</p>

<p>If we step back and consider a team that typically creates PRs that would not be considered RFPRs,
in this case squash merge is probably the right choice. There’s little value in maintaining commit
history in this case, and it makes the commit history a bit easier to review. You simply look at the
commits on <code class="language-plaintext highlighter-rouge">main</code> which each represent a complete changeset.</p>

<p>Otherwise, I think the choice comes down to the git expertise of the team. If everyone has an above
average comfort level with git mechanics, it probably makes sense to <em>consider</em> using merge commits.
It can be easier to find the cause of a particular regression and it makes some other workflows a
bit easier.</p>

<p>I personally prefer to use merge commits but have no issue with using squash merges if the rest of
the team wants to. Like many things of this nature, “It depends”. It’s more important to have
everyone on the team committed to the approach, whatever it is.</p>

<p>Note that if your team is using squash merges, there’s no wasted effort in spending the time to
create the RFPR. Even though your commits will end squashed on <code class="language-plaintext highlighter-rouge">main</code> they will still be preserved
in the PR, and the reviewers will still appreciate that you respect their time and effort spent to
review it.</p>

<h1 id="conclusion">Conclusion</h1>

<p>I hope I’ve been able to convince you that RFPRs are worth the effort. Your teammates will thank you
for this and perhaps you can convince them to also write their own RFPRs.</p>

<h1 id="appendix-commit-order-reviews">Appendix: <a name="CommitOrderReviews"></a>Commit Order Reviews</h1>

<p>If you’ve never reviewed a PR in commit order, it’s worth mentioning that GitHub makes this a bit
easier through keyboard shortcuts. To do this,  click the Commits tab on the PR, and then click the
first commit:</p>

<p><img src="/assets/images/commit-order-reviews.png" alt="lazygit" /></p>

<p>On the commit interface, you can leave comments as you normally would in the “Files changed” tab.
When you’re done leaving feedback you can use the <code class="language-plaintext highlighter-rouge">n</code> and <code class="language-plaintext highlighter-rouge">p</code> keyboard shortcuts to go to the next
and previous commits in the PR, respectively. GitHub has more shortcuts detailed in a dialog that
can be opened by pressing <code class="language-plaintext highlighter-rouge">?</code>.</p>

<p><br />
<br />
<br /></p>

<hr />

<p><em>Many thanks to <a href="https://www.linkedin.com/in/lmarburger/">Larry Marburger</a> and <a href="https://www.linkedin.com/in/mike-heffner/">Mike
Heffner</a> for reviewing ❤️</em></p>]]></content><author><name>Collin</name><email>collin@5xx.engineer</email></author><summary type="html"><![CDATA[Pull requests continue to be the primary mechanism by which we collaborate and contribute code. Despite this we often will put as little effort as possible into creating PRs. I’d like to convince you that even a small investment in improving them pays over-sized dividends to the project and your team members.]]></summary></entry><entry><title type="html">Dotfiles for Greenhorns</title><link href="https://5xx.engineer/2024/11/23/dotfiles.html" rel="alternate" type="text/html" title="Dotfiles for Greenhorns" /><published>2024-11-23T00:00:00-05:00</published><updated>2024-11-23T00:00:00-05:00</updated><id>https://5xx.engineer/2024/11/23/dotfiles</id><content type="html" xml:base="https://5xx.engineer/2024/11/23/dotfiles.html"><![CDATA[<p>If I could go back in time and tell my younger self a few things that would help me be a better
software developer, it would probably be:</p>

<ul>
  <li>read the source, luke.</li>
  <li>read papers.</li>
  <li>create and maintain a dotfiles repo.</li>
</ul>

<p>The first two now seem obvious. Reading the code of the projects you
use gives you insight that you can’t get from reading the documentation. Reading papers like Amazon
Dynamo fits the same bill and in that case, allows you to more fearlessly operate datastores. I
often avoided doing both because it seemed hard, and like anything new it <em>is</em> hard until
you’ve done it a bit and it becomes more natural.</p>

<p>The third entry, a dotfiles repo, is probably a little less obvious. But I really love my dotfiles
repo. Dotfiles are a force multiplier for me. If you don’t have or use one, maybe I can
convince you why you should.</p>

<h1 id="what-is-a-dotfiles-repo">what is a dotfiles repo?</h1>

<p>A dotfiles repo is one that defines your terminal shell experience. This includes scripts to install
and configure utilities you use frequently (e.g. <a href="https://github.com/BurntSushi/ripgrep/">ripgrep</a>,
<a href="https://brew.sh/">homebrew</a>, <a href="https://github.com/neovim/neovim">neovim</a>,
<a href="https://github.com/tmux/tmux/wiki">tmux</a>, <a href="https://git-scm.com/">git</a>, etc). It also is a nice
home to your shell configuration (e.g. configuring <a href="https://ohmyz.sh/">ohmyzsh</a>). Dotfiles are also
where the random bash scripts you write live. Do you install systemd or launchd agents? They can
live here too.</p>

<p>While these things are nice, the real power comes from the fact that all of this configuration is
version controlled. I very frequently find that engineers will simply start fresh when they get a
new job or a new laptop, and add the programs they need as the need arises. While this is wildly
inefficient, it’s insidious in another way:</p>

<blockquote>
  <p>because machines are treated as ephemeral, the investment to customize them is not made.</p>
</blockquote>

<p>This means that you are always using a particular tool as it comes out of the box. Which… is
certainly fine. However, if you’re looking to increase your own power as a developer, you will want to
configure these to bend to your will. And here’s the great thing:</p>

<blockquote>
  <p>a dotfiles lets you make tiny changes easily.</p>
</blockquote>

<p>You don’t really need to configure <em>everything</em> about a particular tool. But if you set up your
dotfiles to allow you to easily change the configuration, then you’ve just removed a huge mental
roadblock. You know exactly where to make the change and you commit it. It’s there
forever and you will never be without that adjustment unless you will it to be so. Over time, these
adjustments will grow and eventually someone will call you a wizard because it looks like
magic watching you control your machine.</p>

<p>Hopefully I’ve convinced you. Let’s chat about how to create a dotfiles repo and get in the flow of
using it. After that I’ll show you some of the things I like best about mine.</p>

<h1 id="create-your-own-dotfiles">create your own dotfiles</h1>

<p>Creating a dotfiles is easy. There are many dotfiles frameworks like
<a href="https://github.com/twpayne/chezmoi">chezmoi</a> that have an opinionated structure and rythym. These
frameworks are great for what they do, but frameworks in general tend to make easy things easier,
and more nuanced things much more difficult as you try to bend the framework to your will for use
cases that were not originally envisioned.</p>

<p>Since many of them are simply bash scripts under the hood, here’s what I suggest:</p>

<blockquote>
  <p>create your own dotfiles repo using shell scripts</p>
</blockquote>

<p>I know… 😱 but trust me. The level of scripting that we are going to do is very basic. And having
some base level of proficiency with the lingua franca of computing has a huge return on investment.
Maintaining your dotfiles will improve your shell scripting proficiency, and
you’ll find that you’ll start writing one-off helpers in bash/zsh more often that will… live in
your dotfiles!</p>

<p>So let’s just do it then.</p>

<div class="language-sh highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">cd</span> ~
<span class="nb">mkdir</span> .dotfiles
<span class="nb">cd</span> .dotfiles
git init
<span class="nb">echo</span> <span class="s1">'echo "Starting .dotfiles install"'</span> <span class="o">&gt;</span> install.sh
<span class="nb">chmod </span>755 install.sh
git add <span class="nt">-A</span>
git commit <span class="nt">-am</span> <span class="s2">"Initial commit."</span>
</code></pre></div></div>

<p>Congrats, you now have a version controlled dotfiles 🎉.</p>

<p>You’ll want to be able to push changes to it so that on a new machine you can clone the repo and
start using it. I’d really recommend creating a <em>public</em> repo. You’ll likely end up sharing your
dotfiles with others or asking questions about a particular script. Having a private repo closes a
lot of doors. You don’t want to put secrets in your dotfiles, and having an open source repo removes
that possibility altogether.</p>

<p>Push your changes. We’ll now start adding to your dotfiles.</p>

<h1 id="bootstrap-your-dotfiles">bootstrap your dotfiles</h1>

<p>The advice I’ll give is based on how I use my own dotfiles repo: <a target="_blank" href="https://github.com/collinvandyck/dotfiles">github.com/collinvandyck/dotfiles</a>. Feel free to
dig around. It may seem like a lot, but it’s not – it’s a lot of little things that just grew over
time, like yours will.</p>

<p>When you created your dotfiles, you added an <code class="language-plaintext highlighter-rouge">install.sh</code> script in the root that just echos to
stdout. Aside from editing the files in your dotfiles, this will be the main way you interact with
your dotfiles. It will bring your machine to the desired end state – your custom development
environment. It takes no arguments. You just run it.</p>

<div class="language-sh highlighter-rouge"><div class="highlight"><pre class="highlight"><code>./install.sh
Starting .dotfiles <span class="nb">install</span>
</code></pre></div></div>

<p>The first thing we’re going to do is to edit the install script to follow some bash norms:</p>

<div class="language-sh highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c">#!/usr/bin/env bash</span>

<span class="nb">set</span> <span class="nt">-e</span> <span class="c"># fail on error</span>
<span class="nb">set</span> <span class="nt">-u</span> <span class="c"># error on undefined variables</span>

<span class="nb">echo</span> <span class="s2">"Starting .dotfiles install"</span>
</code></pre></div></div>

<p>Without <code class="language-plaintext highlighter-rouge">-e</code> bash will happily keep going whenever an error happens. We want to <a href="https://en.wikipedia.org/wiki/Fail-fast_system">fail
fast</a> so that we don’t continue when a command that
subsequent ones depend on has failed. As you hit failures you will need to program around them, and
handle the errors, depending on the context. This will make your dotfiles more relisient and will make
you a better programmer.</p>

<p>The <code class="language-plaintext highlighter-rouge">-u</code> option has a similar effect, failing the script if you try to dereference variables (e.g.
<code class="language-plaintext highlighter-rouge">$MY_URL</code>) when the variable <code class="language-plaintext highlighter-rouge">MY_URL</code> does not exist.</p>

<p>Commit your changes and push them. Years from now I’d suggest using something like
<a href="https://github.com/jesseduffield/lazygit">lazygit</a> to walk through your changes over time. It’s
good to see your progression in this way. <code class="language-plaintext highlighter-rouge">lazygit</code> is a wonderful tool. Why don’t we add it to your
dotfiles so you have it forever?</p>

<h1 id="maintain-your-dotfiles">maintain your dotfiles</h1>

<p>Let’s make our first change and add <code class="language-plaintext highlighter-rouge">lazygit</code> to your dotfiles. Starting out, keep it simple. Just
append to <code class="language-plaintext highlighter-rouge">install.sh</code>. You’ll know when it’s time to break things up, but doing so right now is
counterproductive.</p>

<p>I’m on a mac so I’ll be using the homebrew package manager. Add the following to your <code class="language-plaintext highlighter-rouge">install.sh</code>:</p>

<div class="language-sh highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c"># If brew does not exist on this system, install it.</span>
<span class="k">if</span> <span class="o">!</span> <span class="nb">command</span> <span class="nt">-v</span> brew <span class="o">&gt;</span>/dev/null<span class="p">;</span> <span class="k">then
    </span><span class="nb">echo</span> <span class="s2">"Installing homebrew"</span>
    <span class="c"># from: https://brew.sh/</span>
    /bin/bash <span class="nt">-c</span> <span class="s2">"</span><span class="si">$(</span>curl <span class="nt">-fsSL</span> https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh<span class="si">)</span><span class="s2">"</span>
<span class="k">fi</span>
</code></pre></div></div>

<p>Instead of just running the command to install brew every time, we first check to see if it’s installed.
If you’re not familiar with the <code class="language-plaintext highlighter-rouge">if</code> conditional, <code class="language-plaintext highlighter-rouge">command -v brew</code> outputs the path of the
<code class="language-plaintext highlighter-rouge">brew</code> command, or errors out. But what about the <code class="language-plaintext highlighter-rouge">set -e</code> we added earlier? If you are testing for
the success of the command, as we are, an error will not fail, but will result in a <code class="language-plaintext highlighter-rouge">true</code> for our
if statement because of the <code class="language-plaintext highlighter-rouge">!</code> negation.</p>

<p>Run <code class="language-plaintext highlighter-rouge">./install.sh</code>. If you didn’t have homebrew, you will now. Run it again, and it should not
install it a second time. Commit and push. This is the kind of granular micro commit strategy that
really works well for dotfiles.</p>

<p>And now, it’s time to install <code class="language-plaintext highlighter-rouge">lazygit</code>. Add this to your <code class="language-plaintext highlighter-rouge">install.sh</code>:</p>

<div class="language-sh highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c"># update homebrew</span>
brew update <span class="nt">--quiet</span>
<span class="c"># a sorted list of packages to install</span>
brew <span class="nb">install</span> <span class="nt">--quiet</span> <span class="nt">--formula</span> <span class="se">\</span>
    lazygit <span class="se">\</span>
    <span class="p">;</span>
</code></pre></div></div>

<p>We use the <code class="language-plaintext highlighter-rouge">\</code> syntax to break up a command into multiple lines. The goal here is to have each
package live on its own line. This list will grow over time (I have about 70) and having one package
per line means it’s easy to sort, and having a sorted package list is much easier to maintain.</p>

<p>Go ahead and run <code class="language-plaintext highlighter-rouge">./install.sh</code> again. It should install lazygit. If it didn’t, fix the error.
Once you’re done, commit and push. Again, small, focused commits.</p>

<blockquote>
  <p>having small focused commits makes it easier to roll back changes.</p>
</blockquote>

<p>If you have a huge commit that touches many files, it gets more difficult to back out changes. And a
dotfiles is in the business of making things easier.</p>

<p>At this point, just maintaining a set of installed and up to date homebrew packages on
your machine and any new machine or vm that you may have in the future is a lovely dotfiles. If
that’s all you want, that’s totally fine, and you can be happy with something like this. But if you
push a little bit more the rewards get bigger.</p>

<h1 id="linking-configs">linking configs</h1>

<p><code class="language-plaintext highlighter-rouge">lazygit</code>, and many other utilities, have their own config which lives in a separate file. Unlike
many other utilities, <code class="language-plaintext highlighter-rouge">lazygit</code> on MacOS stores its config in <code class="language-plaintext highlighter-rouge">~/Library/Application Support/lazygit</code>
instead of <code class="language-plaintext highlighter-rouge">~/.config/lazygit</code> which makes it a bit harder to access on the command line. Let’s make it easy.</p>

<p>What we will do is maintain the config for <code class="language-plaintext highlighter-rouge">lazygit</code> within our repo and then <em>symlink</em> that config
into the above path. <code class="language-plaintext highlighter-rouge">lazygit</code> does not care that it’s a symlink. Then we can just make config
changes locally in our repo and it’s automatically reflected via the symlink. You can, and should,
use this pattern when possible for all of the tools you install in your dotfiles.</p>

<p>First, create the config file in a <code class="language-plaintext highlighter-rouge">lazygit</code> folder in the root of your dotfiles:</p>

<div class="language-sh highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">cd</span> ~/.dotfiles    <span class="c"># nice</span>
mdkir <span class="nt">-p</span> lazygit  <span class="c"># use -p so that it doesn't error out if it already exists.</span>
<span class="nb">cd </span>lazygit
<span class="nb">touch </span>config.yml
</code></pre></div></div>

<p>A nice minimal config you can put in config.yml is:</p>

<div class="language-yaml highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="na">git</span><span class="pi">:</span>
  <span class="na">commit</span><span class="pi">:</span>
    <span class="na">autoWrapCommitMessages</span><span class="pi">:</span> <span class="kc">true</span>
    <span class="na">autoWrapWidth</span><span class="pi">:</span> <span class="m">80</span>
</code></pre></div></div>

<p>Save the <code class="language-plaintext highlighter-rouge">config.yml</code> and then append the following to <code class="language-plaintext highlighter-rouge">install.sh</code>:</p>

<div class="language-sh highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c"># create config dir if it does not already exist</span>
<span class="nb">mkdir</span> <span class="nt">-p</span> ~/Library/Application<span class="se">\ </span>Support/lazygit

<span class="c"># link lazygit config</span>
<span class="nb">ln</span> <span class="nt">-s</span> <span class="nt">-f</span> ~/.dotfiles/lazygit/config.yml ~/Library/Application<span class="se">\ </span>Support/lazygit/config.yml
</code></pre></div></div>

<p>Run <code class="language-plaintext highlighter-rouge">./install.sh</code>. Fix any bugs caught by using <code class="language-plaintext highlighter-rouge">set -e</code>. Commit and push.</p>

<p>The <code class="language-plaintext highlighter-rouge">-f</code> option to <code class="language-plaintext highlighter-rouge">ln</code> tells it to overwrite the link if it already exists. If you didn’t have this,
<code class="language-plaintext highlighter-rouge">ln</code> would crash your script when running <code class="language-plaintext highlighter-rouge">install.sh</code> at some point in the future. Idempotency
is king when it comes to dotfiles install scripts.</p>

<p>Congrats, you now have a version controlled lazygit config. You can make changes in your dotfiles
lazygit config instead of trying to remember the actual config lives. You can make changes and later
roll them back if they are not working. Later on you’ll probably end up creating branches to test
out more comprehensive changes so that you can back them all out easily.</p>

<h1 id="linking-shell-init">linking shell init</h1>

<p>Many tools will update your shell init (<code class="language-plaintext highlighter-rouge">.zshrc</code>, <code class="language-plaintext highlighter-rouge">.bashrc</code>, etc) when they install. Other tools,
like <code class="language-plaintext highlighter-rouge">homebrew</code> will ask you to do so, to allow <code class="language-plaintext highlighter-rouge">brew</code> to work correctly in a new shell. After
installing homebrew it suggests to add the following to your shell init:</p>

<div class="language-sh highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">eval</span> <span class="s2">"</span><span class="si">$(</span>/opt/homebrew/bin/brew shellenv<span class="si">)</span><span class="s2">"</span>
</code></pre></div></div>

<p>Let’s add (or modify, if you’ve already added it) this to our <code class="language-plaintext highlighter-rouge">.zshrc</code> (modify for the shell you
use), but with a tweak that we used before:</p>

<div class="language-sh highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">if </span><span class="nb">command</span> <span class="nt">-v</span> /opt/homebrew/bin/brew <span class="o">&gt;</span>/dev/null 2&gt;&amp;1<span class="p">;</span> <span class="k">then
    </span><span class="nb">eval</span> <span class="s2">"</span><span class="si">$(</span>/opt/homebrew/bin/brew shellenv<span class="si">)</span><span class="s2">"</span>
<span class="k">else
    </span><span class="nb">echo</span> <span class="s2">"Homebrew not installed"</span>
<span class="k">fi</span>
</code></pre></div></div>

<p>We check that homebrew is installed first, before performing the eval. You’ll want to add your
dotfiles onto new machines and this avoids a shell error in the case where homebrew has not yet been
installed.</p>

<p>Now that you’ve made that change, let’s add your shell init into your dotfiles! This has the
additional benefit of you being able to see what changes other tools make when you install them.
Since we’ll link <code class="language-plaintext highlighter-rouge">.zshrc</code> in the same way we did before, if some other tool changes your <code class="language-plaintext highlighter-rouge">.zshrc</code> it
will show up as a modification in your git repo. You then have the power to accept the change or
not.</p>

<p>Like we did for <code class="language-plaintext highlighter-rouge">lazygit</code>, create a <code class="language-plaintext highlighter-rouge">zsh</code> folder in your dotfiles repo and copy your shell init into
it:</p>

<div class="language-sh highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">cd</span> ~/.dotfiles
<span class="nb">mkdir</span> <span class="nt">-p</span> zsh

<span class="c"># copy your current .zshrc into your dotfiles .zshrc</span>
<span class="nb">cp</span> ~/.zshrc ~/.dotfiles/zsh/.zshrc
</code></pre></div></div>

<p>Modify your <code class="language-plaintext highlighter-rouge">install.sh</code>:</p>

<div class="language-sh highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">ln</span> <span class="nt">-sf</span> ~/.dotfiles/zsh/.zshrc ~/.zshrc
</code></pre></div></div>

<p>Commit your changes and push. Like <code class="language-plaintext highlighter-rouge">lazygit</code>, you can now also fearlessly make changes to your
zsh configuration.</p>

<h1 id="next-steps">next steps</h1>

<p>We’ve only touched the very surface, but this is a legitimate dotfiles that is all yours
and only needs bash to run.</p>

<p>As you add to this you’ll probably also want to consider:</p>

<ul>
  <li>adding your <code class="language-plaintext highlighter-rouge">git</code> config to your dotfiles.</li>
  <li>creating a <code class="language-plaintext highlighter-rouge">bin</code> folder for your helper scripts, and adding it to the <code class="language-plaintext highlighter-rouge">PATH</code> in your <code class="language-plaintext highlighter-rouge">.zshrc</code>.</li>
  <li>being able to run <code class="language-plaintext highlighter-rouge">install.sh</code> on different operating systems, gracefully.</li>
</ul>

<p>Your dotfiles will evolve over time. And eventually, someone will ask you where you went to
wizarding school.</p>

<p>Go forth and dotfiles!</p>

<hr />

<p><em>Special thanks to <a href="https://bsky.app/profile/ramond.bsky.social">Ray Jenkins</a> for providing helpful
feedback</em></p>]]></content><author><name>Collin</name><email>collin@5xx.engineer</email></author><summary type="html"><![CDATA[If I could go back in time and tell my younger self a few things that would help me be a better software developer, it would probably be: read the source, luke. read papers. create and maintain a dotfiles repo. The first two now seem obvious. Reading the code of the projects you use gives you insight that you can’t get from reading the documentation. Reading papers like Amazon Dynamo fits the same bill and in that case, allows you to more fearlessly operate datastores. I often avoided doing both because it seemed hard, and like anything new it is hard until you’ve done it a bit and it becomes more natural. The third entry, a dotfiles repo, is probably a little less obvious. But I really love my dotfiles repo. Dotfiles are a force multiplier for me. If you don’t have or use one, maybe I can convince you why you should. what is a dotfiles repo? A dotfiles repo is one that defines your terminal shell experience. This includes scripts to install and configure utilities you use frequently (e.g. ripgrep, homebrew, neovim, tmux, git, etc). It also is a nice home to your shell configuration (e.g. configuring ohmyzsh). Dotfiles are also where the random bash scripts you write live. Do you install systemd or launchd agents? They can live here too. While these things are nice, the real power comes from the fact that all of this configuration is version controlled. I very frequently find that engineers will simply start fresh when they get a new job or a new laptop, and add the programs they need as the need arises. While this is wildly inefficient, it’s insidious in another way: because machines are treated as ephemeral, the investment to customize them is not made. This means that you are always using a particular tool as it comes out of the box. Which… is certainly fine. However, if you’re looking to increase your own power as a developer, you will want to configure these to bend to your will. And here’s the great thing: a dotfiles lets you make tiny changes easily. You don’t really need to configure everything about a particular tool. But if you set up your dotfiles to allow you to easily change the configuration, then you’ve just removed a huge mental roadblock. You know exactly where to make the change and you commit it. It’s there forever and you will never be without that adjustment unless you will it to be so. Over time, these adjustments will grow and eventually someone will call you a wizard because it looks like magic watching you control your machine. Hopefully I’ve convinced you. Let’s chat about how to create a dotfiles repo and get in the flow of using it. After that I’ll show you some of the things I like best about mine. create your own dotfiles Creating a dotfiles is easy. There are many dotfiles frameworks like chezmoi that have an opinionated structure and rythym. These frameworks are great for what they do, but frameworks in general tend to make easy things easier, and more nuanced things much more difficult as you try to bend the framework to your will for use cases that were not originally envisioned. Since many of them are simply bash scripts under the hood, here’s what I suggest: create your own dotfiles repo using shell scripts I know… 😱 but trust me. The level of scripting that we are going to do is very basic. And having some base level of proficiency with the lingua franca of computing has a huge return on investment. Maintaining your dotfiles will improve your shell scripting proficiency, and you’ll find that you’ll start writing one-off helpers in bash/zsh more often that will… live in your dotfiles! So let’s just do it then. cd ~ mkdir .dotfiles cd .dotfiles git init echo 'echo "Starting .dotfiles install"' &gt; install.sh chmod 755 install.sh git add -A git commit -am "Initial commit." Congrats, you now have a version controlled dotfiles 🎉. You’ll want to be able to push changes to it so that on a new machine you can clone the repo and start using it. I’d really recommend creating a public repo. You’ll likely end up sharing your dotfiles with others or asking questions about a particular script. Having a private repo closes a lot of doors. You don’t want to put secrets in your dotfiles, and having an open source repo removes that possibility altogether. Push your changes. We’ll now start adding to your dotfiles. bootstrap your dotfiles The advice I’ll give is based on how I use my own dotfiles repo: github.com/collinvandyck/dotfiles. Feel free to dig around. It may seem like a lot, but it’s not – it’s a lot of little things that just grew over time, like yours will. When you created your dotfiles, you added an install.sh script in the root that just echos to stdout. Aside from editing the files in your dotfiles, this will be the main way you interact with your dotfiles. It will bring your machine to the desired end state – your custom development environment. It takes no arguments. You just run it. ./install.sh Starting .dotfiles install The first thing we’re going to do is to edit the install script to follow some bash norms: #!/usr/bin/env bash set -e # fail on error set -u # error on undefined variables echo "Starting .dotfiles install" Without -e bash will happily keep going whenever an error happens. We want to fail fast so that we don’t continue when a command that subsequent ones depend on has failed. As you hit failures you will need to program around them, and handle the errors, depending on the context. This will make your dotfiles more relisient and will make you a better programmer. The -u option has a similar effect, failing the script if you try to dereference variables (e.g. $MY_URL) when the variable MY_URL does not exist. Commit your changes and push them. Years from now I’d suggest using something like lazygit to walk through your changes over time. It’s good to see your progression in this way. lazygit is a wonderful tool. Why don’t we add it to your dotfiles so you have it forever? maintain your dotfiles Let’s make our first change and add lazygit to your dotfiles. Starting out, keep it simple. Just append to install.sh. You’ll know when it’s time to break things up, but doing so right now is counterproductive. I’m on a mac so I’ll be using the homebrew package manager. Add the following to your install.sh: # If brew does not exist on this system, install it. if ! command -v brew &gt;/dev/null; then echo "Installing homebrew" # from: https://brew.sh/ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" fi Instead of just running the command to install brew every time, we first check to see if it’s installed. If you’re not familiar with the if conditional, command -v brew outputs the path of the brew command, or errors out. But what about the set -e we added earlier? If you are testing for the success of the command, as we are, an error will not fail, but will result in a true for our if statement because of the ! negation. Run ./install.sh. If you didn’t have homebrew, you will now. Run it again, and it should not install it a second time. Commit and push. This is the kind of granular micro commit strategy that really works well for dotfiles. And now, it’s time to install lazygit. Add this to your install.sh: # update homebrew brew update --quiet # a sorted list of packages to install brew install --quiet --formula \ lazygit \ ; We use the \ syntax to break up a command into multiple lines. The goal here is to have each package live on its own line. This list will grow over time (I have about 70) and having one package per line means it’s easy to sort, and having a sorted package list is much easier to maintain. Go ahead and run ./install.sh again. It should install lazygit. If it didn’t, fix the error. Once you’re done, commit and push. Again, small, focused commits. having small focused commits makes it easier to roll back changes. If you have a huge commit that touches many files, it gets more difficult to back out changes. And a dotfiles is in the business of making things easier. At this point, just maintaining a set of installed and up to date homebrew packages on your machine and any new machine or vm that you may have in the future is a lovely dotfiles. If that’s all you want, that’s totally fine, and you can be happy with something like this. But if you push a little bit more the rewards get bigger. linking configs lazygit, and many other utilities, have their own config which lives in a separate file. Unlike many other utilities, lazygit on MacOS stores its config in ~/Library/Application Support/lazygit instead of ~/.config/lazygit which makes it a bit harder to access on the command line. Let’s make it easy. What we will do is maintain the config for lazygit within our repo and then symlink that config into the above path. lazygit does not care that it’s a symlink. Then we can just make config changes locally in our repo and it’s automatically reflected via the symlink. You can, and should, use this pattern when possible for all of the tools you install in your dotfiles. First, create the config file in a lazygit folder in the root of your dotfiles: cd ~/.dotfiles # nice mdkir -p lazygit # use -p so that it doesn't error out if it already exists. cd lazygit touch config.yml A nice minimal config you can put in config.yml is: git: commit: autoWrapCommitMessages: true autoWrapWidth: 80 Save the config.yml and then append the following to install.sh: # create config dir if it does not already exist mkdir -p ~/Library/Application\ Support/lazygit # link lazygit config ln -s -f ~/.dotfiles/lazygit/config.yml ~/Library/Application\ Support/lazygit/config.yml Run ./install.sh. Fix any bugs caught by using set -e. Commit and push. The -f option to ln tells it to overwrite the link if it already exists. If you didn’t have this, ln would crash your script when running install.sh at some point in the future. Idempotency is king when it comes to dotfiles install scripts. Congrats, you now have a version controlled lazygit config. You can make changes in your dotfiles lazygit config instead of trying to remember the actual config lives. You can make changes and later roll them back if they are not working. Later on you’ll probably end up creating branches to test out more comprehensive changes so that you can back them all out easily. linking shell init Many tools will update your shell init (.zshrc, .bashrc, etc) when they install. Other tools, like homebrew will ask you to do so, to allow brew to work correctly in a new shell. After installing homebrew it suggests to add the following to your shell init: eval "$(/opt/homebrew/bin/brew shellenv)" Let’s add (or modify, if you’ve already added it) this to our .zshrc (modify for the shell you use), but with a tweak that we used before: if command -v /opt/homebrew/bin/brew &gt;/dev/null 2&gt;&amp;1; then eval "$(/opt/homebrew/bin/brew shellenv)" else echo "Homebrew not installed" fi We check that homebrew is installed first, before performing the eval. You’ll want to add your dotfiles onto new machines and this avoids a shell error in the case where homebrew has not yet been installed. Now that you’ve made that change, let’s add your shell init into your dotfiles! This has the additional benefit of you being able to see what changes other tools make when you install them. Since we’ll link .zshrc in the same way we did before, if some other tool changes your .zshrc it will show up as a modification in your git repo. You then have the power to accept the change or not. Like we did for lazygit, create a zsh folder in your dotfiles repo and copy your shell init into it: cd ~/.dotfiles mkdir -p zsh # copy your current .zshrc into your dotfiles .zshrc cp ~/.zshrc ~/.dotfiles/zsh/.zshrc Modify your install.sh: ln -sf ~/.dotfiles/zsh/.zshrc ~/.zshrc Commit your changes and push. Like lazygit, you can now also fearlessly make changes to your zsh configuration. next steps We’ve only touched the very surface, but this is a legitimate dotfiles that is all yours and only needs bash to run. As you add to this you’ll probably also want to consider: adding your git config to your dotfiles. creating a bin folder for your helper scripts, and adding it to the PATH in your .zshrc. being able to run install.sh on different operating systems, gracefully. Your dotfiles will evolve over time. And eventually, someone will ask you where you went to wizarding school. Go forth and dotfiles! Special thanks to Ray Jenkins for providing helpful feedback]]></summary></entry><entry><title type="html">Hello World!</title><link href="https://5xx.engineer/2024/11/07/hello-world.html" rel="alternate" type="text/html" title="Hello World!" /><published>2024-11-07T00:00:00-05:00</published><updated>2024-11-07T00:00:00-05:00</updated><id>https://5xx.engineer/2024/11/07/hello-world</id><content type="html" xml:base="https://5xx.engineer/2024/11/07/hello-world.html"><![CDATA[<p>I’ve been wanting a blog for a while but never felt like I had the time for it. Lately, that’s
changed, so I’ve put this site together. I’m a programmer by trade, and going forward my goal is to
have this site be a mix of personal and technical writing. Watch this space :)</p>

<!--more-->]]></content><author><name>Collin</name><email>collin@5xx.engineer</email></author><summary type="html"><![CDATA[I’ve been wanting a blog for a while but never felt like I had the time for it. Lately, that’s changed, so I’ve put this site together. I’m a programmer by trade, and going forward my goal is to have this site be a mix of personal and technical writing. Watch this space :)]]></summary></entry></feed>