new alias

Hi,

I wrote a new alias:

alias cls=clear

The thing is I couldn’t make this alias works when I boot the computer. Also this alias does not work in other shell screens.

How do I make to do that !?

Thanks in advance for any feedback.

Resoliving this issue, will resolve other more complex.

regards,

agunet74

You wrote an alias, but where did you put it?

Aliases are part of the environment, so they only live as long as a process where it is added to the environment (by the alias command you showed) and it’s offspring live.

When you only give the command in a shell, it will last until you finish that shell.

When you put it in a file ~/.alias, of a user, it will be available in all shells of that user, because in .bashrc there is:

henk@boven:~> grep alias .bashrc
test -s ~/.alias && . ~/.alias || true
henk@boven:~> 

This has nothing to do with boot. It is a user feature and after you add it in .alias, it will work in all newly started shells. Thus at the most you have to logout/login to have it available.

Aliases, like environment variables, are per-environment, meaning per
process/environment/shell. If you want an alias in multiple
terminals/shells, you need to set it in them or set things globally and
then be sure you start a new shell to read that new configuration.

For your user, modify the ~/.alias file (/home/youruserhere/.alias) with
the alias definition, then launch a new shell and see if it works.

If you really want a quick way to clear your screen, though, just use
Ctrl+l (el, as in the letter, not the number).


Good luck.

If you find this post helpful and are logged into the web interface,
show your appreciation and click on the star below…

Aliases, like environment variables, are per-environment, meaning per
process/environment/shell. If you want an alias in multiple
terminals/shells, you need to set it in them or set things globally and
then be sure you start a new shell to read that new configuration.

For your user, modify the ~/.alias file (/home/youruserhere/.alias) with
the alias definition, then launch a new shell and see if it works.


Good luck.

If you find this post helpful and are logged into the web interface,
show your appreciation and click on the star below…

Ctrl+Ĺ works fine, just wat I’m lookiong for, thanks