Why “alias” is my last resort for aliases
Published on: 2025-07-03 03:35:30
Aliases were one of the first things I added when customizing my dotfiles. For example, here’s a very early alias I defined:
alias g =git
Now, I can run g instead of git , which saves me a little time for a command I run dozens of times a day!
# These two commands are now equivalent: git status g status
I used to define these aliases with alias . After all…I’m defining an alias!
But over time, I think I discovered a better way: a script in my $PATH .
How it works
In my home directory, I have a folder of scripts called bin . For example, here’s a simplified version of ~/bin/g :
#!/usr/bin/env bash exec git " $@ "
Running this script basically just runs git .
I add this folder to my $PATH . (See Julia Evans’s guide on how to do this.) In my .zshrc , I have a line like this:
export PATH = " $HOME /bin: $PATH "
Now, when I type g , it runs that script.
This behaves just like an alias. As before, g status and git status are equivalent.
# These two commands are still the same:
... Read full article.