Re: Automating alias saving in bash
From: Chris F.A. Johnson (c.f.a.johnson_at_rogers.com)
Date: 09/05/03
- Next message: John Murtari: "Re: Linux periodicals"
- Previous message: Chris F.A. Johnson: "Re: Automating alias saving in bash"
- In reply to: Chris F.A. Johnson: "Re: Automating alias saving in bash"
- Next in thread: Anssi Porttikivi: "Re: Automating alias saving in bash"
- Reply: Anssi Porttikivi: "Re: Automating alias saving in bash"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 5 Sep 2003 17:06:20 GMT
On Fri, 05 Sep 2003 at 17:01 GMT, Chris F.A. Johnson wrote:
> On Fri, 05 Sep 2003 at 11:40 GMT, Anssi Porttikivi wrote:
>> This is my hack. I am not very satisfied, do you know any better
>> way to do this?
>>
>> #! /bin/bash
>> # .bashrc
>> # Source from .aliases, watch for changes since startup of this shell.
>> . .aliases
>> alias >/tmp/aliases$$
>> #
>> # All user shells add their new aliases to the end of .aliases at exit.
>> # BUG/FEATURE!
>> # Redefining aliases leaves redundant old lines in .aliases file.
>> # You can get rid of them by the hacked unalias below.
>> trap 'alias | cat - /tmp/aliases$$ | sort | uniq -u >>.aliases' EXIT
>> #
>> # BUG/HACK! Unalias is nullified by the output of the alias trap above.
>> # This hack makes it work,
>> # but overwrites recent aliases gathered from other shells.
>> alias unalias='rm /tmp/aliases$$ ~/.aliases; unalias'
>>
>
> $ cat ~/.logout
> alias >> ~/.aliases
> awk -F= '
> { alias[$1]=$0 }
> END {
> for ( a in alias )
> print alias[a]
> }
> ' ~/.aliases
Amend the last line to:
' ~/.aliases > /tmp/aliases$$
mv -b /tmp/aliases$$ ~/.aliases
--
Chris F.A. Johnson http://cfaj.freeshell.org
===================================================================
My code (if any) in this post is copyright 2003, Chris F.A. Johnson
and may be copied under the terms of the GNU General Public License
- Next message: John Murtari: "Re: Linux periodicals"
- Previous message: Chris F.A. Johnson: "Re: Automating alias saving in bash"
- In reply to: Chris F.A. Johnson: "Re: Automating alias saving in bash"
- Next in thread: Anssi Porttikivi: "Re: Automating alias saving in bash"
- Reply: Anssi Porttikivi: "Re: Automating alias saving in bash"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|