[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Setting up aliases to work also in tty* consoles?



On Tue, Jun 20, 2017 at 04:06:24PM +0100, Rodolfo Medina wrote:
> I settle down permamnent bash aliases by simply putting them in the file
> ~/.bash_aliases; but they only work within X environment.  Is it possible, and
> how?, to make them work also in tty1, tty2, ..., i.e. out of graphical
> surround?

Shell aliases and functions should be declared in ~/.bashrc or in a file
that you source from ~/.bashrc.  Some people like to create a ~/.bash_aliases
and source that from ~/.bashrc -- that's fine.  Sounds like you are doing
that.

The other step is that you need to ensure ~/.bashrc gets sourced from
your login profile, so that it gets picked up by ALL interactive shells
(login and non-login).  If you have a ~/.bash_profile or ~/.bash_login,
make sure you source ~/.bashrc from there.  Otherwise, if you don't
have those, make sure you source it from ~/.profile.

When you login on a text console, you get a login shell, which reads
~/.bash_profile or ~/.bash_login or ~/.profile but not ~/.bashrc.
(Which is why you need that extra source step.)

When you run a terminal emulator within an X session, you *typically*
get a non-login shell, which reads ~/.bashrc only.


Reply to: