Today i came across this neat feature but unfortunately i have a problem with it.
~/.bashrc
<----------------------------
export HISTCONTROL=erasedups
---------------------------->
$ history
1 history
$ top
$ htop
$ top
$ htop
$ history
1 top
2 htop
3 history
i close this shell and open a new terminal:
$ history
1 top
2 htop
3 history
$ top
$ htop
i close this shell again and *now* i get:
$ history
1 top
2 htop
3 top
4 htop
5 history
So it seems to me entries already written to ~/.bash_history are not
"eliminated".
Is this the supposed behaviour?
man bash:
<---------------------------------------------------------------
A value of erasedups causes all previous lines matching the current line
to be removed from the history list before that line is saved.
--------------------------------------------------------------->
>From that i would think only *one* appearance of entries that are the same
would be saved.
please give me a hint.
TIA Thilo
--
i am on Ubuntu 2.6 KDE
- some friend of mine
gpg key: 0x4A411E09
<snip>
sorry forgot to mention:
$ echo $BASH_VERSION
3.2.13(1)-release
The erasedups feature works correctly: it removes matching commands
from the history list, which is kept in memory. When the shell exits,
by default it appends the current history list to the history file.
If you want to force the history file to be completely rewritten, you
can use `history -w' at shell exit to rewrite it. There is, unfortunately,
currently no easy way to force the `rewrite-at-exit' behavior.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
Live Strong. No day but today.
Chet Ramey, ITS, CWRU ch...@case.edu http://cnswww.cns.cwru.edu/~chet/
Could a shell trap be used to do this?
trap 'history -w' EXIT
I did not test this however. It is just a "brainstorm" idea.
Bob
That's the way to force `history -w' at shell exit. There is no variable
setting to make that behavior the default without using a trap, however.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
Live Strong.
Chet Ramey, ITS, CWRU ch...@case.edu http://tiswww.tis.case.edu/~chet/
<snip>
> If you want to force the history file to be completely rewritten, you
> can use `history -w' at shell exit to rewrite it.
$ top
$ htop
$ top
$ htop
$ history
1 top
2 htop
3 history
$ history -w
in new shell:
$ history
1 top
2 htop
3 history -w
4 top
5 htop
6 history -w
7 history
> There is, unfortunately,
> currently no easy way to force the `rewrite-at-exit' behavior.
:( ic
I have tried this trap thingy also, but unfortunatly it doesn´t work either
it seems.
> Chet
OK then thank you and i would like to open a wishlist bug for it. ;)
bye Thilo
<snip>
> OK then thank you and i would like to open a wishlist bug for it. ;)
...and in the interim we probably should add a notice to the manpage, that
erasedups currently deons´t work session persistent.