Re: default bash history (non)preservation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 11 Apr 2023 10:48:11 -0400
"Chris Murphy" <lists@xxxxxxxxxxxxxxxxx> wrote:

> Hi,
> 
> For a long time I've noticed lost history from multiple Terminal
> tab/windows. It seems like the last tab or window to close is the
> history that gets written to .bash_history, and everything else is
> just lost.
> 
> Somehow I found this:
> https://web.archive.org/web/20090815205011/http://www.cuberick.com/2008/11/update-bash-history-in-realtime.html
> 
> I've implemented the suggested two line change to .bash_profile:
> 
> # User specific environment and startup programs
> shopt -s histappend
> PROMPT_COMMAND="history -a;$PROMPT_COMMAND"
> 
> The resulting behavior appears to be shells still have their own
> unique histories while active. But once closed, their histories
> become merged (interlaced based on the time they were issued?) and
> available when a new shell is created.
> 
> I think this would be a pretty cool yet subtle Fedora 39 feature.
> However, 
> 
> a) I'm uncertain exactly where this belongs as a default, .bashrc or
> .bash_profile or some parent file that's copied to create these files
> (for new users); 

I like option 3 if it is going to be automatic.

> b) if this is (still) an optimal way to go about it;

Providing it without effort or awareness for users seems like the way
to go.

> c) what are the possible negative side effects?

I can't think of any.  What good is a history that doesn't include all
the commands that have been used?  Well, complex commands.  I've turned
off some common commands, like ls, because all they are is clutter.  I
also turned off saving duplicate commands, though that only works if
they are contiguous in history.  I think that would be a downside to
this if people weren't used to all the clutter in their history.
Though, with Ctrl-R, it really doesn't matter.

I actually wrote a little python program to load history, and eliminate
all duplicate commands in history while preserving order of the
commands.  So, the last duplicate command is always the one saved.
> 
> Any thoughts?

I have the following defined in .bashrc:

# this logs the history explicitly before exiting a shell
hx ()
{
  history -a;
  exit;
}

It means that I have to exit using the command hx when closing a
terminal.  Not as elegant as an automatic process you are suggesting,
but it seems to work.  I'll have to try the process you are
suggesting, (from the link you gave), to see if it results in the
same effect.
_______________________________________________
devel mailing list -- devel@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/devel@xxxxxxxxxxxxxxxxxxxxxxx
Do not reply to spam, report it: https://pagure.io/fedora-infrastructure/new_issue




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Fedora Announce]     [Fedora Users]     [Fedora Kernel]     [Fedora Testing]     [Fedora Formulas]     [Fedora PHP Devel]     [Kernel Development]     [Fedora Legacy]     [Fedora Maintainers]     [Fedora Desktop]     [PAM]     [Red Hat Development]     [Gimp]     [Yosemite News]

  Powered by Linux