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
Forum Regular
Forum Regular

Joined: Wed Aug 02, 2006 12:12 pm
Posts: 684
Has thanked: 197 times
Have thanks: 13 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
Forum Veteran
Forum Veteran
User avatar

Joined: Wed Jul 12, 2006 1:42 am
Posts: 4584
Has thanked: 486 times
Have thanks: 633 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.


Fri Apr 27, 2012 11:19 am

Adrian thanked by: eemaestro, lucky9
Profile
Forum Regular
Forum Regular

Joined: Wed Aug 02, 2006 12:12 pm
Posts: 684
Has thanked: 197 times
Have thanks: 13 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
Forum Regular
Forum Regular

Joined: Wed Aug 02, 2006 12:12 pm
Posts: 684
Has thanked: 197 times
Have thanks: 13 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
Forum Veteran
Forum Veteran
User avatar

Joined: Wed Jul 12, 2006 1:42 am
Posts: 4584
Has thanked: 486 times
Have thanks: 633 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).


Mon Apr 30, 2012 11:59 am
Profile
Forum Veteran
Forum Veteran
User avatar

Joined: Wed Jul 19, 2006 6:13 am
Posts: 10228
Location: Geneva NY
Has thanked: 2962 times
Have thanks: 1897 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.

_________________
Production: 32 bit, 3.14-0.bpo.1-686-pae. MX-14.2, AMD FX-4130 Quad-Core, GeForce GT 630/PCIe/SSE2, 8 GB DDR3, / and /home on Kingston SSD 120 GB, data on WesternDigital 1TB, Dell SP2309W monitor.


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: No registered users 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.