Better Shell Aliases

I use shell aliases quite heavily to simplify common CLI commands. However, one of my biggest pain points when using them is they didn’t work as well in certain complex commands.

For example, suppose I have the following alias in my Fish config that assigns the task command to an alias t:

alias t="task"

Now I can run commands like this:

t add Buy groceries

But with a complex command like this, it doesn’t work:

seq 10 | xargs -I {} t add Testing {}

I found that a simple solution was to simple create a binary in addition to the alias. For the t alias, this would look like this:

#!/usr/bin/env bash

task "$@"

Now, you could just create the binary and remove the alias, but the alias ensures fish can provide autocompletion properly, so I find that the combination of both gives the best of both worlds.