How to create a permanent "alias" for ubuntu?

If you create an alias, for example:

alias cls="clear" 

It exists until you end the terminall session. When you launch a new terminal window, the alias no longer exists. How to create a "persistent" alias that exists in every terminal session?

+6
source share
1 answer

You can put such aliases in the ~ / .bash_aliases file.

This file is loaded by ~ / .bashrc. On Ubuntu 10.04, the following lines should be uncommented to allow the use of ~ / .bash_aliases. On Ubuntu 11.04 and later, it is already activated:

 if [ -f ~/.bash_aliases ]; then . ~/.bash_aliases fi 

also

You can add the function below to your .bashrc file.

Permalias () function

 { alias "$*"; echo alias "$*" >> ~/.bash_aliases } 

Then open a new terminal or run the source ~ / .bashrc in the current terminal. Now you can create persistent aliases using the permalias command, for example permalias cls = clear.

+7
source

Source: https://habr.com/ru/post/956905/


All Articles