Do you type common commands directly into the command line, or endlessly scroll up with the arrow keys? Wouldn't it be better if you could shorten this down into one word or letter?
Take this, for example:
$ flutter pub build_runner build --delete-conflicting-outputs
In a Dart environment this starts the
build_runner for code generation. Unlike Node and
pub doesn't have a direct task runner, so you may find yourself running the same tasks often across multiple projects.
Instead, I can just run:
$ build # Runs: flutter pub build_runner build --delete-conflicting-outputs $ build:watch # Runs: flutter pub build_runner watch --delete-conflicting-outputs
You could even shorten it down to
br, or anything of your choice. Here's how:
You may want to create a file that you can keep in source control that can be used across different computers and environments. I've elected to name this
.zsh_aliases, but you can name this whatever you want:
alias build="flutter pub run build_runner build --delete-conflicting-outputs" alias build:watch="flutter pub run build_runner build --delete-conflicting-outputs"
Then, open up your
.bashrc and add the following line:
[ -f .zsh_aliases ] && source .zsh_aliases
This'll check to make sure that the file exists and if so, add it to the current context by using
Save your file and then re-open your terminal. You should now be able to execute the alias commands anywhere.
Join the newsletter to receive the latest updates in your inbox.