Re: A Feature Request for History

2011-06-13 Thread Bradley M. Kuhn
Jayesh Badwaik wrote at 03:18 (EDT) on Saturday:

> Every now and then I want a command from one of the instances of bash
> to be used in another instance. In that case, the history of bash is
> not that useful since it is quiet linear in nature and does not store
> history of all bash instances.

That's not entirely correct.  Bash can be configured to store history
from multiple bash instances and not overwrite.  Here's what I use in my
bashrc to accomplish this:

HISTSIZE=1048576
HISTFILESIZE=1048576
set histappend=true

LAST_HISTORY_WRITE=$SECONDS
function prompt_command {
if [ $(($SECONDS - $LAST_HISTORY_WRITE)) -gt 300 ]; then
history -a
LAST_HISTORY_WRITE=$SECONDS
fi
...
}

This makes sure that all my bash instances save their history and that I
never lose a command.  I have all my bash history going back to
2003-10-15 accessible to me.

The only feature you describe above missing with that configuration is
that existing shells won't find history commands written out
in-between.  I have a tendency to close/open bash shells, so I don't run
into that problem.

Unfortunately, having looked recently at the history code, I think
adding a feature whereby existing running shells "notice" the history
file has changed would be a large rewrite to the history code.  I think
that would be a useful optional feature, though.

> I would like to propose another method of storing the history, just
> like git stores its commits, by using the some kind of hash of the
> command.

I'm not convinced this would accomplish anything of use.  The hashes
would be quite large, and typing them would be annoying, even with tab
completion.

One thing I do is keep my bash_history file in git, by making
.bash_history a symlink to a file in a directory which is stored in
Git.  Perhaps doing that would help you keep better track of your
commands?

-- 
   -- bkuhn



Re: A Feature Request for History

2011-06-13 Thread Chet Ramey
On 6/13/11 1:10 PM, Bradley M. Kuhn wrote:

> The only feature you describe above missing with that configuration is
> that existing shells won't find history commands written out
> in-between.  I have a tendency to close/open bash shells, so I don't run
> into that problem.
> 
> Unfortunately, having looked recently at the history code, I think
> adding a feature whereby existing running shells "notice" the history
> file has changed would be a large rewrite to the history code.  I think
> that would be a useful optional feature, though.

People have had success using `history -a' and `history -n' to accomplish
this.  The idea is to append your latest command to some common history
file, then use history -n to read other shells' commands into your
history list.

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/



Re: documentation bug re character range expressions

2011-06-13 Thread Andre Majorel
On 2011-06-09 12:40 -0700, Marcel (Felix) Giannelia wrote:

> Guess it's time I really learned how to navigate texinfo...

You can spare yourself the pain with something along the lines
of

#!/bin/sh
info --subnodes -o- "$1" | less

(Which won't help you in this particular case as neither bash nor
bash-doc contain any .info files, at least not on Debian.)

-- 
André Majorel http://www.teaser.fr/~amajorel/



Re: A Feature Request for History

2011-06-13 Thread Michael Witten
On Mon, Jun 13, 2011 at 17:10, Bradley M. Kuhn  wrote:
> I have all my bash history going back to
> 2003-10-15 accessible to me.

Why?