Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel sail (docker) bash alias not remembering [duplicate]

I've created a new Laravel application using docker and Laravel Sail. I've used Ubuntu on my Windows 11 computer to store my application using sail. Everything works as intended and I can access my application.

The problem I'm experiencing is that every time I need to run Laravel Sail commands I need to type in the full path: ./vendor/bin/sail (command). I know the way to add a bash alias is the following:

alias sail='[ -f sail ] && bash sail || bash vendor/bin/sail'

The issue is that every time I open up Ubuntu using my Windows terminal, or reset my computer, this alias is gone. I'll have to re-apply the command into the terminal to use the alias again, until the next computer refresh.

How can I make sure this bash alias sticks, instead of having to type this out every single time I have to restart my computer?

like image 382
n212 Avatar asked Sep 07 '25 03:09

n212


1 Answers

You can add alias depending on the terminal you're using, If you're using zsh or bash

If zsh then run

nano ~/.zshrc

and then add alias - alias sail='[ -f sail ] && bash sail || bash vendor/bin/sail'

source ~/.zshrc

if you are using bash run in your terminal

nano ~/.bash_profile

and then add alias - alias sail='[ -f sail ] && bash sail || bash vendor/bin/sail',

 source ~/.bash_profile
like image 142
Heena Manglani Avatar answered Sep 10 '25 00:09

Heena Manglani