Question about history handling #500
-
Hello Everyone, Great piece of software. I have a question about the way history is being handled. Coming from plain bash, I had many lines pertaining to history. When installing OMB I renamed .bashrc to .bashrc.orig. I know it would have backed up the original file, but I renamed it anyway. I am still getting duplicates in my .bash_history file. Does the /lib/history.sh library handle all the duplicates or do I still need to add something to the .bashrc file? On line 35 and 36 of the /lib/history.sh file, there is no 'export' to HISTCONTROL=. Maybe it doesn't need it, I'm no expert. Does it only handle the history in memory? I typed 'git status' three times and notice it did not add all three. But if I return and open a new terminal window, it will add another one and not remove the existing one. So far, I have many of them in the .bash_history file. How do I get rid of those. Like I mention, I did not add much to the bashrc file. Just some cargo/env and fzf stuff. Nothing pertaining to history. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
This is a consequence of To force the
It's unrelated. There is no need to export
See https://unix.stackexchange.com/a/78846/121088. In case the timestamp is also included in the history file, you would probably need to preserve the lines starting with $ cp ~/.bash_history ~/.bash_history.backup
$ tac ~/.bash_history.backup | awk '/^# / || !mark[$0]++' | tac > ~/.bash_history If you are in Solaris, please use |
Beta Was this translation helpful? Give feedback.
-
Great answer. You really summed it up. Thank you. I have also been using ble.sh. The auto-complete and suggestions are working great. It even suggested commands with no history at all. I use a powerful little log navigator called LNAV as soon as I started to type I noticed ble.sh has some lines of code related to history also. In your opinion should I be using both? I haven't uncommented any of the settings in ble.sh in fear it may create some race condition. Are there plans to merge all these technologies? All of your hard work on these Bash projects is really appreciated. |
Beta Was this translation helpful? Give feedback.
-
Check out this little gem here. Very tiny but quite effective (except the ghosted timestamps) |
Beta Was this translation helpful? Give feedback.
This is a consequence of
history -a
called in PROMPT_COMMAND and in theme definitions. The new entry is written to the history file immediately after the command is executed. So, even if the duplicate entries are removed from the in-memory history byerasedups
, the entries that are already written to files remain. Sinceshopt -s histappend
is specified, the history file will not be retroactively rewritten on the session end.To force the
erasedups
to the history file, you need to turn off the synchronized history; You need to comment out line 27 oflib/history.sh
, and also removehistory -a;history -c;history -r
in each theme file …