← Notes

When a Shell Alias Should Become a Script

If a shortcut needs an argument, a conditional, or a comment, it has probably outgrown a one-line shell alias.

Aliases are good for fixed substitutions such as gco='git checkout'. I stop using one when the command needs to inspect input or quote an argument. Shell functions can bridge the gap, but a small script is easier to test and can travel between shells.

My rough rule is simple: the first conditional earns a file. Giving the shortcut a real name and a short help message also makes it less mysterious six months later.