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

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



Greg Wooledge <wooledg@eeg.ccf.org> writes:

> 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.


According to what you say, I solved my problem by putting my aliases in
~/.bash_profile rather than in ~/.bash_aliases.  I don't know if it's correct,
but it works.

Thanks,

Rodolfo


Reply to: