2

I used to be able to use up and down arrow to find my history, including failed commands that did return a different retval, correct them and try again. After I installed fzf something changed, and now I only have successful commands in my history which return a value, everything else simply isn't there.

I suspect I've either changed something in one of my script configs, or fzf changed something:

  • .bashrc
  • .fzf.bash
  • .profile
  • .bash_profile

Unfortunately this is extremely annoying and I've no idea how to fix it. For example, typing:

which python
sudo apt-cache

produces in .bash_history:

#1601901660
which python

but not the sudo apt-cache command.

Running the following command:

 grep HIST ~/.bashrc ~/.profile ~/.bash_profile ~/bash.login ~/.bash_aliases /etc/bash.bashrc /etc/profile /etc/profile.d/* /etc/environment .fzf.bash 2>/dev/null

Produces:

/home/tons/.bashrc:HISTCONTROL=ignoreboth
/home/tons/.bashrc:HISTSIZE=
/home/tons/.bashrc:HISTFILESIZE=
/home/tons/.bashrc:export HISTTIMEFORMAT="%h %d %H:%M:%S "
/home/tons/.bashrc:export HISTSIZE=10000
/home/tons/.bashrc:export HISTFILESIZE=10000
/home/tons/.bashrc:export HISTCONTROL=ignorespace:erasedups
/home/tons/.bashrc:export HISTIGNORE="ls:ps:history"
/home/tons/.bashrc:export HISTIGNORE="s*"
3
  • 1
    Please post the output of grep HIST ~/.bashrc ~/.profile ~/.bash_profile ~/bash.login ~/.bash_aliases /etc/bash.bashrc /etc/profile /etc/profile.d/* /etc/environment .fzf.bash 2>/dev/null so we can see your history settings. – terdon Oct 5 '20 at 17:26
  • @terdon thanks for the help, much appreciated! I suspect it's HISTIGNORE that changed something? – Alex Oct 6 '20 at 9:44
  • HISTIGNORE="s*" should explain missing sudo. But not commands starting with something other than an s. – ilkkachu Oct 6 '20 at 9:57
2

The HISTIGNORE variable is a way of telling bash's history system to ignore certain commands. Here, you are setting that to:

export HISTIGNORE="s*"

Note that this will overwrite the earlier HISTIGNORE="ls:ps:history". More importantly, this s* tells bash not to store any commands starting with s in the history, which nicely explains why your sudo apt-cache isn't stored: sudo starts with an s.

1
  • That explains a lot, I don't even know how that ended up in there (most likely a copy-paste from shellhacks.com/tune-command-line-history-bash). EDIT: yes I'm an idiot I blindly copied the lines from the above blogpost! – Alex Oct 6 '20 at 10:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.