skip to Main Content

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?

2

Answers


  1. 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
    
    Login or Signup to reply.
  2. Add alias sail=’bash vendor/bin/sail’ in your .bashrc in your home directory if you are using ubuntu dont know about windows

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search