Skip to content

Clean $HOME, Clean Mind

I don’t like a messy home. Home is where all your stuff lives and if you want to find something, it’s easier if there’s not a bunch of clutter in the way. This is true in your physical home and your digital $HOME. Most Linux distributions and macOS populate your $HOME with directories you never asked for. The difference is whether you can rid yourself of them. On Linux they come from xdg-user-dirs. You can remove or disable it, delete the directories, and they stay gone. macOS has no such switch: delete its home directories and the system quietly recreates them. So on the Mac you can’t remove them… but you can hide them. ...

Porcelain

A little indicator on my prompt tells me the state of the git repo I’m in, if I’m in one. It’s quite minimal. Green tick: repo is clean; yellow cross: there are changes; red dot: there are merge conflicts. It’s a nice visual cue and for the longest time and the following code in my ~/.zshrc file made it possible. 1 2 3 4 5 6 7 8 9 10 git_status_prompt() { git rev-parse --git-dir >/dev/null 2>&1 || return if git diff --name-only --diff-filter=U 2>/dev/null | grep -q .; then echo " %F{red}●%f" elif git status --porcelain 2>/dev/null | grep -q .; then echo " %F{yellow}✘%f" else echo " %F{green}✓%f" fi } This works fine. It does what it’s supposed to… It’s ugly though. ...

Change Directory, List

When moving around in my terminal, I use two commands in sequence all the time. You’ll know them, they are cd and ls. Change directory, then list the contents of that directory. I decided this was getting annoying. Why is there not a single command to do this? Why not make one? I first thought an alias might work, but then I realised you cannot call an alias, hand it a variable and have it do something after that variable. <alias> <user variable> <second action> is just not possible. ...

Unquarantine

It’s great that your OS tries to protect you from yourself, because let’s face it, you don’t always make the best decisions. When you download an app macOS slaps a com.apple.quarantine extended attribute on it. This is what triggers Gatekeeper’s super duper handy popup asking you if you are really, truly sure you want to open a thing you just deliberately downloaded. If you could just click OK on this and move on, that’d be fine. It’s a little reminder that “hey, you did a thing you might not want to do”. And it does this sometimes. Other times it will flat out deny you running it. You’d have to go into settings and click through menus to allow the application in order to actually launch it. This is going too far. Luckily a single terminal command will handle it in one fell swoop. ...

Rsync

Rsync is an amazing utility to copy (or sync) stuff from one place to another without having to worry about the command getting cut. With a plain cp, an interrupted transfer means starting over from scratch. Rsync compares source and destination, skipping files that are already there, and with --partial it can even resume a file that was only halfway through. It can also remember ownership and permissions, and even copy over ssh. That is, with the right flags, which I can never remember. Hence this post. ...

Format On MacOS

I’m used to formatting disks on Linux with GParted, but unfortunately there’s no version for MacOS. They offer some sort of bootable image, but that sounded like a hassle. Luckily it turns out MacOS has a built-in tool. Usage is simple. I wanted to format a drive to ExFat, and all it takes is: 1 diskutil list To list the drives on your system and find the name of the one you want to format. Then: ...

Terminal Abbreviations

Typing takes time. Typing without typos is an art. Fixing mistakes in a terminal command is a pain in the neck. Luckily there’s such a thing as aliases. An alias lets you set a keyword and a command it should expand to. For example, I have set a super simple one, which is widely used: alias ..='cd ..'. This allows me to write .. in terminal and it will act like cd .., saving me typing a c, a d and a space. This seems minor, but when you imagine how often I need to go up a directory in terminal, it’s a huge timesaver. ...