JP Vossen on 13 Sep 2007 16:58:45 -0000 |
Date: Thu, 13 Sep 2007 09:22:28 -0400 From: Dan Widyono <dan@widyono.net> Subject: Re: [PLUG] Bash History question
If you are interested in synchronizing the history across different sessions/shells/pids or however you want to think about it, you can. At a high level, there are two ways to do it: manually or "automatically." <Shameless plug: this is basically recipe 16.11 of _bash Cookbook_> For the manual method, you simply use the built-in bash tools to sync into the current shell: history -a history -n --or-- "history sync" alias hs='history -a ; history -n' '-a' means to append history lines from this session to the history file. '-n' means to read all history lines not already read from the history file and append them to the history list. For the automatic method, you can use: PROMPT_COMMAND='history -a ; history -n' The problem here is that $PROMPT_COMMAND contains a command to run just before the prompt is displayed, *every time*. So anything you put there gets run a *lot* and may slow down an older or heavily used system. I tend to use a history with 5000 lines, so I personally would not use $PROMPT_COMMAND. Also, the manual method has a bit of a chicken and egg problem in that if you sync shell_1, then shell_2, then shell_3, 1&2 won't have 3's history. You basically have to loop through them all twice at one time to be sure.
Hope this is useful, JP ----------------------------|:::======|------------------------------- JP Vossen, CISSP |:::======| jp{at}jpsdomain{dot}org My Account, My Opinions |=========| http://www.jpsdomain.org/ ----------------------------|=========|------------------------------- Microsoft has single-handedly nullified Moore's Law. Innate design flaws of Windows make a personal firewall, anti-virus and anti-malware software mandatory. The resulting software arms race has effectively flattened Moore's Law on hardware running Windows. ___________________________________________________________________________ Philadelphia Linux Users Group -- http://www.phillylinux.org Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce General Discussion -- http://lists.phillylinux.org/mailman/listinfo/plug
|
|