🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix.shell
Article #4023

Re: bash history: saving to and restoring from different file

#4023
From: jellybean stonerfish
Date: Sat, 20 Sep 2008 17:56
53 lines
2963 bytes
On Sat, 20 Sep 2008 11:01:09 -0400, S P Arif Sahari Wibowo wrote:

> On Sat, 20 Sep 2008, jellybean stonerfish wrote:
>> From man bash
> 
> Thanks. Unfortunately the man page does not give the exact moment in a
> bash session the history is restored from or saved to the file. Can be
> quite helpful information.

Try adding a HISTFILE=/home/js/filename to your .bashrc or .bash_profile.
Then open a shell and see what history file was loaded, and also what 
HISTFILE is set to.  Maybe putting the line one of your startup files is 
better than putting it in your .logout file.  With a little trial and 
error, you will figure it out.  If not then try adding a line with
{ sleep 10s; HISTFILE=/home/js/filename } to .bashrc or .bash_profile
that might do it.

> 
>> js@blackbox:~$ 
>> js@blackbox:~$ echo $HISTFILE
>> /home/js/filename
>> js@blackbox:~$ exit
> 
> Right. But this is manual intervention. I guess I need to clarify that
> my question is how to do it automatically, i.e. just seconds after the
> history is restored from $HISTFILE pointing the file A, $HISTFILE should
> automatically change to file B.
> 
>> HISTFILE=filename
>> to you .bash_logout
> 
> Thanks. But there are 2 issues with this approach:
> 
> - Will the history saving happen before or after .bash_logout executed?

Testing it on your system is the best way to answer that question.  Maybe 
setting HISTFILE in a startup file would work better so you can use
history -a .


> 
> - That does not help when I use "history -a" in my shell, which I do
> sometime and I am planning to do more often (automated).

> 
> 
> Any other idea?
> 
> Thanks!

Good luck, and let us know if you figure it out.

stonerfish
Technical Details
Message-ID: <1PaBk.76633$Qu7.8756@newsfe25.ams2>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!feeder.news-service.com!newsfeed.freenet.de!ramfeed2.eweka.nl!lightspeed.eweka.nl!81.171.88.16.MISMATCH!eweka.nl!hq-usenetpeers.eweka.nl!69.16.177.246.MISMATCH!cyclone03.ams.highwinds-media.com!news.highwinds-media.com!npeersf01.ams.highwinds-media.com!newsfe25.ams2.POSTED!8a64a38d!not-for-mail
References: <alpine.OSX.1.10.0809191320370.13605@imac2006.local> <O72Bk.808$as4.535@nlpi069.nbdc.sbc.com> <alpine.OSX.1.10.0809201050320.13605@imac2006.local>

Show Full Headers
Complete Article Headers
X-Google-Thread: 1012a6,6f426515059a57b0
X-Google-Thread: 1054c0,6f426515059a57b0
X-Google-Attributes: gid1012a6,gid1054c0,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!feeder.news-service.com!newsfeed.freenet.de!ramfeed2.eweka.nl!lightspeed.eweka.nl!81.171.88.16.MISMATCH!eweka.nl!hq-usenetpeers.eweka.nl!69.16.177.246.MISMATCH!cyclone03.ams.highwinds-media.com!news.highwinds-media.com!npeersf01.ams.highwinds-media.com!newsfe25.ams2.POSTED!8a64a38d!not-for-mail
From: jellybean stonerfish <stonerfish@geocities.com>
Subject: Re: bash history: saving to and restoring from different file
Newsgroups: comp.unix.shell,gnu.bash
References: <alpine.OSX.1.10.0809191320370.13605@imac2006.local>
 <O72Bk.808$as4.535@nlpi069.nbdc.sbc.com>
 <alpine.OSX.1.10.0809201050320.13605@imac2006.local>
User-Agent: Pan/0.129 (Benson & Hedges Moscow Gold)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Lines: 53
Message-ID: <1PaBk.76633$Qu7.8756@newsfe25.ams2>
X-Complaints-To: abuse2@dslextreme.com
NNTP-Posting-Date: Sat, 20 Sep 2008 17:56:13 UTC
Organization: DSL Extreme
Date: Sat, 20 Sep 2008 17:56:13 GMT