Using Stow to Make Managing Your Dotfiles Easier

As someone who regularly switches between various macOS and Linux machines, keeping my dotfiles synced everywhere gets a bit annoying. Fortunately, I've recently come across a tool called Stow from GNU, which helps you manage your dotfiles.

Stow, combined with a git repository, makes managing and syncing dotfiles between devices much, much easier.

To install Stow, you'll likely find it in your package manager under "stow". For example, for macOS running Homebrew, you'd literally just need to run brew install stow.


As for using Stow, it's probably useful to first know how it works. That way you'll have a better picture of how it ties everything together.

Let's take this scenario - you have your Neovim configuration saved under ~/.config/nvim like normal.

If you want to synchronise this between devices, then maybe you could just turn that directory into a git repository itself.

But if you have a bunch of configs for tools, some in .config, others inside your home directory, and some just plain config files mixed in there, it can get a bit messy.

That's where Stow comes in. You can have a central place where you store all your configurations for various tools. And then you can then choose to "stow" (load into the relevant directory) the configuration for whichever tool you want.

This means you can have one git repository, with a collection of individually defined packages, which then can be synchronised to various devices. And then on each of these devices, you can choose a subset of these packages to use.

Let's go back to a real world scenario again. Let's say this is your home directory:

.
├── .config/
│   ├── nvim/
│   │   ├── init.lua
│   │   └── lua/
│   │       └── stuff.lua
│   └── tmux/
│       └── tmux.conf
└── .zshrc

You can see there are three different things being configured, Neovim, tmux, and zsh. With Stow, you could have these as three differently defined packages.

Each package in stow, is defined by it being a directory with its name being the package name. Inside the directory would be the folder structure as if it were in the home directory.

This would mean, the above configuration inside a central dotfiles directory, would look like this:

.
├── nvim/
│   └── .config/
│       └── nvim/
│           ├── init.lua
│           └── lua/
│               └── stuff.lua
├── tmux/
│   └── .config/
│       └── tmux/
│           └── tmux.conf
└── zsh/
    └── .zshrc

With that dotfile directory, to configure all of these packages in the local machine, you would just need to run this command in the directory:

stow nvim tmux zsh

That command would then load all of the packages, by creating a symbolic link from all the relevant files and folders into the correct place.

To get an example, here is a screenshot showing my .config directory with all the symbolic links, and my .dotfile directory.

Just as a tip, the default behaviour of the stow [package] command, is that it works when you are in a directory that is one level below your home directory.

You can read the full capabilities of the stow command via the man page, or via the documentation. However, if you want a simpler life, you can just do what I do, and create a directory for your dotfiles like this: ~/.dotfiles/.


Once you start building up your collection of config packages, and tracking the directory via git, it becomes really easy to move between machines.

All you would need to do is to pull the git repository, and then use stow to load whichever packages you wanted to load on that particular machine.

You could even have slightly different versions of a given configuration, and then load a specific version based on the machine you were on. Maybe you have something that fits your use case at work or home, or even a different platform such as Mac or Linux.

Once you start using it, it doesn't take long until you start to feel the benefits.

A Father

6 days ago, on the 4th of July, the best thing happened to me.

I became a father.

hello

Some Recent Bash Scripting Fun

I've been writing more and more bash scripts recently (GitHub repo). It started when I was playing around with a script called tmux-sessionizer from The Primeagen, that uses fzf to search for directories in a preset location, and then open the selected directory in a tmux session.

The first three I came up with were all mainly some sort of selector-style tools powered by fzf:

(they may seem like odd names, but I wanted to be able to use these scripts really quickly)

  • tg (right-top)- a customed version of tmux-sessionizer that lets you quickly fuzzy find a directory and then attach/reattach to a tmux session with it.
  • ala (left)- fuzzy finder for alacritty (my terminal choice) themes, which is then applied on selection.
  • fd (right-bottom) - fuzzy finder that searches the current directory for any subdirectories with a max depth of 3. And then changes into the selected directory.

I also made another one that replaces my existing alias for quickly committing and pushing my local changes with Git, and makes the flow a bit more interactive.

Previously I had an alias gacp, which basically meant (to me) "git add commit push", and did the following:

git add --all
git commit -m "$input"
git push

And I'd use it like this:

gacp "my wonderful code change"

But now with my (aptly) named tool, gt, I just need to type those two letters, and it then lets me quickly run through the process of pushing my latest changes.

First of all, it asks if I want to stage all my current changes (defaults to yes), then it asks what type of commit it is (using conventional commit style), asks for a commit message, and then if I want to push to my remote repo.

So a pretty simple process, but just a bit faster thanks to this little script.

As you can see, I'm clearly having a bit of fun writing these scripts, so don't be surprised when I start uploading even more.

Although my next script/tool will definitely have to be making blog posts easier to start writing. I have a half-baked bash script that creates a basic template, but I think I want to make one with a bit more power, that can be flexible for multiple types of posts. Let's see.

A CLI Tool to Post to Micro.Blog

I've been working on a small command line tool recently. It's essentially a simple way to write a short post on Micro.blog from the command line, called pst.

It's probably not the typical place people tend to do their microblogging. But I did it for a few reasons:

  1. I live in a terminal when I use a computer, so it's easy for me to quickly write a post, or share a link. I don't always have Micro.blog open.
  2. There's obviously less distractions when you can just post and carry on with whatever you were doing.
  3. It's a simple idea, so it would be perfect to use it as a learning oppurtunity.
  4. I don't get many ideas for small projects like this, so I have to run with them. Otherwise I'd never build anything.

So, now you know the reasons, I'll explain a bit more about pst, how to install it, configure your blog, and also how to use it.

First of all, you can install pst from crates.io or homebrew:

crates.io

cargo install pst

homebrew

brew tap chrishannah/pst
brew install pst

To configure pst, all you need to do is to generate an app token from Micro.blog (find that in your Account settings), and then store that in a JSON file under ~/.config/pst/config.json. The specific format is in the README.

Using pst is pretty simple, you have the pst command, followed by the type (post or draft), and then your content. Examples:

pst draft "don't show this to anyone"

pst post "hello, losers!"

After that, you'll see some handy links in the terminal for where you can view, preview, or edit the post on Micro.blog.

I forgot to also say that it's built with Rust! I'd been wanting to write something in Rust for a while, but it was never the right time, and I also didn't have the correct project. Luckily for me, it's a small project, so I decided to use it to learn some Rust.

Obviously I haven't used it for long (or for much), but I've really enjoyed using the language. And especially for these types of tools, I can see myself using Rust even more in the future. (Especially because I have my Neovim config working perfectly with Rust now.)

Apple vs the World

I can't say I'm completely up to date with Apple's various ongoing issues with various government entities, so I can't exactly offer any well thought out opinions. And I also want to say that I'm not exactly that interested in getting into the weeds of it all.

I'm sure in all cases, Apple are right in some areas, and wrong in others. However, what I'm more intruiged in, is the long-term effect that it will have on Apple as a company, and also on the products it builds.

The changes could be related to hardware, software, how Apple's devices interact with devices of other companies, the restrictions they apply to their stores, or it could even affect the company itself. Either way, I'm sure something will end up changing as a result of these various battles.

I'm no longer a die-hard Apple fan, so I'm not going to get overly caught up on any of the arguments for or against them. But there's a reason people talk about Apple's "walled garden". And rightly or wrongly, it seems that more and more people are starting to want to tear down the wall.

Rethinking Phone Battery Life

When I've pictured my "ideal" phone in the past, I've regularly had long battery life as one of the key features. But I've thought about battery life as something that hasn't improved. Because most people have probably been charging their phone every night for quite some time.

However, you could probably argue that battery life has always been increasing. The problem is, so have our demands.

Sure, more powerful chips require more energy to run. So an iPhone 15 will naturally require more resources than an iPhone 5. At the same time, we also weren't expecting an iPhone 15 to record 4K HDR video without affecting the battery life.

It's probably not a big revelation to many. But it's a perspective that might be worth considering when judging the evolution of technology.

The Rabbit R1

I finally watched the Rabbit R1 announcement video earlier, and while I think it's a really raw product and has a lot to prove, I was definitely wowed by it. Maybe it's the hardware design (which was done in partnership with Teenage Engineering), or the idea that this will actually be able to do things for you, rather than just be another conversational AI. Either way, shortly after watching the video, I decided to pre-order an R1.

The relatively low entry price for the R1 at $199/£160 definitely helped. But I also wanted to put my money where my mouth was. Since products like the Rabbit R1 and others like the Human Ai Pin are examples of the direction that I want technology to move towards.

In my ideal world, technology would be used to help us understand, explore, and experience the world around us. Rather than keep us locked away in digital worlds, cut off from people around us. No matter how "connected" it can make us feel when we've got a screen constantly in front of our face.

I'm hopeful that we're moving in the right direction.

My Relationship With the iPad

I have a weird relationship with my iPad. I can go months without using it all, and then suddenly something switches in me, and I want to use it for everything.

While I'm not trying to blame anyone, I think a lot of this comes from me falling for the "what is a real computer" or the "everyone can work from an iPad" hype that used to be quite common on the internet.

Now I'm not saying either those are objectively true or false, or that I want to try and change anyone else's opinions on the iPad. But whenever I pick up my iPad Pro, without any case or keyboard attached, it feels magical to me. It feels like I'm using a computer from a science fiction show[1].

It's because of that feeling, coupled with the conversations around it having the ability to be your only computer, I start wanting to do more things with it. I attach the Magic Keyboard because then it looks like a laptop, and that's a real computer, so it must mean it becomes better. I also then occasionally connect a mouse, or even play around with the Apple Pencil, because this clearly makes it a more capable computer.

Yet every time, it leads me to getting irritated with the quirks/drawbacks of the iPad and then avoiding it for another month (or few). Instead of just letting the iPad be the magical device that it can be for me.

I need to learn how to just enjoy things for what they are, and not try to dream up weird and wonderful scenarios that add needless complexities and friction in my life.


  1. Don't take this as me thinking the iPad is a perfect computer. But that's not important right now. ↩︎

Artifact is Already Shutting Down

The Artifact team announcing the news via their Medium blog:

We’ve made the decision to wind down operations of the Artifact app. We launched a year ago and since then we’ve been working tirelessly to build a great product. We have built something that a core group of users love, but we have concluded that the market opportunity isn’t big enough to warrant continued investment in this way. It’s easy for startups to ignore this reality, but often making the tough call earlier is better for everyone involved. The biggest opportunity cost is time working on newer, bigger and better things that have the ability to reach many millions of people. I am personally excited to continue building new things, though only time will tell what that might be. We live in an exciting time where artificial intelligence is changing just about everything we touch, and the opportunities for new ideas seem limitless.

On one hand I'm dissapointed that an app that I enjoy to use will soon be no more. On the other hand, it's not really surprising. I found it to be a great way to surface content that I was interested in (although the quality did drop in recent times), however the reading experience in the app wasn't the greatest. Even so, it still made my "Software I’ve Enjoyed in 2023" list last year.

I assume this is the case for other people as well, but at least for myself, I would have used the service a lot more if it had some form of web interface.

Also, isn't it a bit weird that this news was posted on a Medium blog? I can understand wanting it in a more permanent place outside of the actual Artifact app, since that will soon stop working. But Medium? Not their own artifact.news domain, or even just a blogging platform with a better reading experience than something like Medium. Maybe that sort of decision shows why the app was like it was.

My First Project of 2024

It's only been just a week, and I've already "completed" my first project of the year. Well, it's not really completed, but it's functional and it already completely addresses a personal need.

The project is a simple plugin for Neovim that helps me generate the initial frontmatter I need for my blog posts. It's called blogutils.nvim, so you can imagine it may grow in the future. But right now, it has three pieces of functionality:

  • formatTitle - Format specified input as AP Title Case via Text Case CLI.
  • formatSlug - Format specified input as a slug via Text Case CLI.
  • generateFrontMatter - Uses the first line of the current buffer as an input, then generates a title, slug, gets the current date, and adds the relevant frontmatter to the top of the file.

Here's a short video showing me generating the frontmatter from an example title:

I may improve it in the future, but right now that's all I need it for. And with how smoothly the development went, I'm really interested in the idea of making more plugins in the future.

Additionally, the act of learning how to write a Neovim plugin has made me much more comfortable using Neovim generally. It's weird to think that just months ago I could barely even use vim motions.


I've also created a new page for my 2024 projects, which now has just a single entry. I plan on using this page to document the projects I work on (big and small) throughout the year, grouped by week. You can also find in the menu bar the top, titled "2024".

I wanted to group by week because I wanted to visualise my work over the year in more granularity. I just hope I build enough things to make it an interesting list.