Skip to main content

Command Palette

Search for a command to run...

Using bash aliases to shorten lengthy commands

Updated
1 min read
Using bash aliases to shorten lengthy commands
J

Back-end software developer with expertise in PHP, TypeScript, JavaScript, and Java development, as well as a passion for applying best practices in software architecture and design. Views are my own.

I remember my times using Lumen. I did not know composer scripts back then so I had to type vendor/bin/phpunit painstakingly when running my tests.

I used bash aliases to shorten commands. I have the alias created on my Dockerfile on build-time. Like so:

# Add bash alias for PHPUnit
RUN echo 'alias phpunit="vendor/bin/phpunit"' >> ~/.bashrc
RUN source ~/.bashrc

After building the image, there is no need to type the lengthy command anymore. Just run the new alias and my tests would run as usual!

$ phpunit

Moreover, you can make use of the same technique and create bash aliases for other lengthy commands in your Docker container.