How to define a global alias in BASH?

4

I'm using Terminal in Linux and I'm tired of repeating the same commands all the time.

For example, I use a command almost all day, so I create an alias to make things easier.

Example:

  alias tt="php artisan tinker --env=local"

  alias artisan="php artisan --env=local"

However, every time the Terminal is closed, these shortcuts "go to the bag". So I have to define everything again when I open Terminal again or restart my Ubuntu ;

How can I make these% global%? Do you have any way to do this?

    
asked by anonymous 10.05.2016 / 19:15

2 answers

4

You can add these lines to the /etc/profile file. As soon as the user logs in, the information is loaded.

$ sudo vim /etc/profile
ou
$ sudo nano /etc/profile

profile:

#...
alias tt="php artisan tinker --env=local"
alias artisan="php artisan --env=local"
  

To apply the changes, you must log out.

    
10.05.2016 / 20:27
2

Place your aliases inside the /home/$USER/.bashrc file.

This file runs every time you open a graphical terminal.

Add, preferably, your aliases at the end of the file.

For example, you can use nano to edit this file:

 sudo  nano /home/$USER/.bashrc

Then you can add any alias:

artisan="php artisan --env=local"
    
10.05.2016 / 19:19