Git Product home page Git Product logo

Comments (9)

akinomyoga avatar akinomyoga commented on June 11, 2024

Yes, you are right. That is the behavior of Bash. Or do you see any difference in the behavior with and without ble.sh?

In the first place, the in-memory command history and the history file is not synchronized for every command. It is only synchronized when the Bash session ends or you run history -w or history -a (depending on your preference). The command history -c only clears the in-memory command history. If you would like the in-memory history to be reflected in the history file, you need to run history -w in a row.

If you expect the in-memory history to be reflected in the history file on the session end (including the removal of entries), please make sure the shell option histappend is turned off (i.e., `shopt -u histappend).

from ble.sh.

blackteahamburger avatar blackteahamburger commented on June 11, 2024

But after running shopt -u histappend, history -c still doesn't clean ~/.bash_history.

from ble.sh.

akinomyoga avatar akinomyoga commented on June 11, 2024

shopt -u histappend is just a setting to control the behavior on the session end. Changing the setting doesn't immediately clean ~/.bash_history. You need to exit the session for shopt -u histappend to take an effect.

If you would like to reflect the content of the in-memory command history into the history file immediately, you need to run history -w.

from ble.sh.

akinomyoga avatar akinomyoga commented on June 11, 2024

P.S. "the session end" means that you exit the current Bash session by running exit, by pressing C-d on an empty command line, or by closing the terminal window.

from ble.sh.

blackteahamburger avatar blackteahamburger commented on June 11, 2024

In fact I ran history -c, exited the session and ~/.bash_history still wasn't cleaned up.

from ble.sh.

akinomyoga avatar akinomyoga commented on June 11, 2024

The behavior you reported does not reproduce in my environment. I tried bash-5.1 and 5.2. I also tried it with and without oh-my-bash and bash-completion. Always, the consequence of history -c is reflected to ~/.bash_history when the Bash session ends in my environment.

  • Q1: Does the reported behavior reproduce with a plain Bash plus ble.sh (without any other configurations)?

from ble.sh.

akinomyoga avatar akinomyoga commented on June 11, 2024
  • Q2: Could you give me the result of the following command?
$ ble/widget/display-shell-version

from ble.sh.

blackteahamburger avatar blackteahamburger commented on June 11, 2024

After I manually deleted ~/.bash_history, it strangely became clearable with history -c.
I don't know why but it works fine now.

from ble.sh.

akinomyoga avatar akinomyoga commented on June 11, 2024

Thanks for the information. Hmm, one possibility is that it was caused by the permission of the file. When I change the permission of the history file as chmod 400 ~/.bash_history, I can reproduce the behavior of not clearing the file content, though it doesn't allow appending new entries in ~/.bash_history either.

from ble.sh.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.