MEPIS Community Forum

A Linux operating system based on Debian Stable
View unanswered posts | View unsolved topics | View active topics |



Reply to topic  [ 6 posts ] 
Aliases in multiple shell instances 
Author Message
MEPIS is cool!
MEPIS is cool!

Joined: Wed Aug 02, 2006 12:12 pm
Posts: 594
Has thanked: 133 times
Have thanks: 9 times
Post # 299181
Post Aliases in multiple shell instances
I noticed that when I am typing in a Konsole window, an alias
that I defined in a different Konsole window is undefined.
Has anybody figured out a way to automatically share aliases among shell instances, so I don't have to type in my alias in
different shells?
I can define all my aliases in a Bash-script file called aliases. But how would I have the shell instance automatically run that script when I switch to it (or when I create it )?


Fri Apr 27, 2012 10:20 am
Profile
MEPIS Enthusiast
MEPIS Enthusiast
User avatar

Joined: Wed Jul 12, 2006 1:42 am
Posts: 4040
Has thanked: 327 times
Have thanks: 444 times
Post # 299183
Post Re: Aliases in multiple shell instances
You have to call that aliases script from .bashrc which gets executed every time you open a shell. I have in mine these lines:
Code:
if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases
fi

Of course change .bash_aliases to whatever file name you use.

You could also put the aliases directly in .bashrc, but it's nicer to keep them in a separate file.

_________________
Nobody is born with knowledge, knowledge comes from manuals and Google (and our beloved Wiki)


Fri Apr 27, 2012 11:19 am

Adrian thanked by: eemaestro, lucky9
Profile
MEPIS is cool!
MEPIS is cool!

Joined: Wed Aug 02, 2006 12:12 pm
Posts: 594
Has thanked: 133 times
Have thanks: 9 times
Post # 299198
Post Re: Aliases in multiple shell instances  [Solved]
Thank you, Adrian.
I used the filename you suggested. I moved my aliases script file from aliases to the name you suggested. It worked! Thank you.

BTW, I was surprised to get this message
Code:
$ls -a *alias*
ls: cannot access *alias*: No such file or directory


I thought that -a would include files beginning with a dot. Didn't show anything. I had to do this:
Code:
$ ls -a .*alias*
.bash_aliases   .bash_aliases.bak  .bash_aliases.txt.bak
.bash_aliases~  .bash_aliases.txt  .bash_aliases.txt.bk3


Fri Apr 27, 2012 2:54 pm
Profile
MEPIS is cool!
MEPIS is cool!

Joined: Wed Aug 02, 2006 12:12 pm
Posts: 594
Has thanked: 133 times
Have thanks: 9 times
Post # 299267
Post Re: Aliases in multiple shell instances
Adrian,

I followed your example. I consolidated all my aliases into one file. Now it works automatically when I create a new Konsole window. I need no longer redefine my desired alias.

Thank you for helping me. I appreciate it.


Sun Apr 29, 2012 2:25 pm
Profile
MEPIS Enthusiast
MEPIS Enthusiast
User avatar

Joined: Wed Jul 12, 2006 1:42 am
Posts: 4040
Has thanked: 327 times
Have thanks: 444 times
Post # 299291
Post Re: Aliases in multiple shell instances
Glad to be of help. I went one more step and put my .bash_aliases in my Dropbox and then linked it to home so I have the same aliases no matter what computers I use. I've done the same for .bash_functions

(will move to Google drive once they release a linux client).

_________________
Nobody is born with knowledge, knowledge comes from manuals and Google (and our beloved Wiki)


Mon Apr 30, 2012 11:59 am
Profile
MEPIS Enthusiast
MEPIS Enthusiast
User avatar

Joined: Wed Jul 19, 2006 6:13 am
Posts: 8665
Location: Geneva NY
Has thanked: 2317 times
Have thanks: 1521 times
Post # 299292
Post Re: Aliases in multiple shell instances
I think this is right: aliases stored in .bashrc in the /home directory will not work in a root terminal. The file would need to be copied and pasted (as root) into the /root directory.

_________________
A Wiki only works when many eyes are on it.

32bit, 3.12-0.bpo.1-686-pae, MX-14, AMD Phenom 9650 Quad-Core, Dell SP2309W with integrated webcam, Nvidia GeForce 6150SE, 4 GB DDR2


Mon Apr 30, 2012 12:07 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 6 posts ] 

Who is online

Users browsing this forum: loco and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Protected by Anti-Spam ACP Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.