Score:1

"bash --noprofile --norc" destroys .bash_history

bd flag

While I have HISTFILESIZE and HISTSIZE greater than 500, the bash history gets destroyed after I entered to a "norc" shell. How can I keep the history data through the various shell types?

Here's an actual example.

// on the normal shell (bash)
/mnt/c/pg$ wc ~/.bash_history
  876  1997 19855 /home/user/.bash_history

/mnt/c/pg$ logout

PS > bash --noprofile --norc

// on the norc shell
bash-4.4$ wc ~/.bash_history
  847  1947 19406 /home/user/.bash_history
// -> notice that .bash_history is trimmed to the default 500 lines. This is the problem.

bash-4.4$ exit

// again on the normal shell
PS > bash

/mnt/c/pg$ wc ~/.bash_history
  848  1948 19439 /home/user/.bash_history
// -> once I enter to a norc shell, it affects the entire shell experiences

Here's a part of my .bashrc and .profile

// .bashrc

export HISTCONTROL=ignoredups:erasedups  # no duplicate entries
export HISTSIZE=100000                   # big big history
export HISTFILESIZE=100000               # big big history
shopt -s histappend                      # append to history, don't overwrite it

// .. 
// .profile

export HISTCONTROL=ignoredups:erasedups  # no duplicate entries
export HISTSIZE=100000                   # big big history
export HISTFILESIZE=100000               # big big history
shopt -s histappend                      # append to history, don't overwrite it

// .. 
muru avatar
us flag
Maybe instead of using `--norc`, use `--rcfile` with a file containing just these options? Or set `HISTFILE` to some non-default path, say `~/.histfile` instead of `~/.bash_history`, then the `--norc` shell will use the default path and leave your actual history alone.
Score:0
in flag

Run it with empty HISTFILE, so the shell will not try to update the default file:

HISTFILE= bash --noprofile --norc
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.