How do I define "persistent" bash aliases? (Solved)

Using applications, configuring, problems
Post Reply
Message
Author
rga
Posts: 2
Joined: Wed 31 Aug 2011, 19:27

How do I define "persistent" bash aliases? (Solved)

#1 Post by rga »

Hi everyone,
I have a problem with defining bash aliases.
I have tried putting them in ~/.bash_aliases as I do in Ubuntu, and I have also tried to put them in ~/.bashrc but i can't get them to work.

I'm using Lucid 5.2.8
Last edited by rga on Sat 03 Sep 2011, 18:02, edited 1 time in total.

User avatar
fratermus
Posts: 20
Joined: Thu 28 May 2009, 22:05
Location: 75081
Contact:

Re: How do I define "persistent" bash aliases?

#2 Post by fratermus »

rga wrote:Hi everyone,
I have tried putting them in ~/.bash_aliases as I do in Ubuntu, and I have also tried to put them in ~/.bashrc but i can't get them to work.
.bashrc should work, but you'd have to start a new term (or source the dotfile) to see it in the current session.
Eee 900 (16GB SSD), 2GB RAM, Puppy Linux 5.1.1

rga
Posts: 2
Joined: Wed 31 Aug 2011, 19:27

Re: How do I define "persistent" bash aliases?

#3 Post by rga »

fratermus wrote:
rga wrote:Hi everyone,
I have tried putting them in ~/.bash_aliases as I do in Ubuntu, and I have also tried to put them in ~/.bashrc but i can't get them to work.
.bashrc should work, but you'd have to start a new term (or source the dotfile) to see it in the current session.
Thank you!

Starting a new terminal or running the file from the terminal didn't work (or maybe I did something wrong).

But after a reboot the aliases defined in .bashrc were loaded when i opened the terminal :)

User avatar
fratermus
Posts: 20
Joined: Thu 28 May 2009, 22:05
Location: 75081
Contact:

Re: How do I define "persistent" bash aliases?

#4 Post by fratermus »

rga wrote:Starting a new terminal or running the file from the terminal didn't work (or maybe I did something wrong).

But after a reboot the aliases defined in .bashrc were loaded when i opened the terminal :)
Running a script (like .bashrc) by name like that really means "load a child shell, run this script in that child shell, then close that shell and fall back to the current/parent shell". In this manner changes made in the child die with it and are not available to the parent unless you go out of your way to preserve them.

". .bashrc" would keep the aliases as long as you were in that terminal session. The first dot means "source the following file", basically as if you typed it on the (current) shell. It does not invoke a child shell.

I hope I have not made matters worse. :-)
Last edited by fratermus on Mon 05 Sep 2011, 13:53, edited 1 time in total.
Eee 900 (16GB SSD), 2GB RAM, Puppy Linux 5.1.1

Post Reply