1

I added a line to ~/.bashrc file which appends all issued commands to ~/.bash_eternal_history file in a date directory history-number command format, such as:

 2019-01-08.23:59:32    /home/sport/Desktop   745  pwd

I need a reverse-i-search feature to bring up commands from my custom history file ~/.bash_eternal_history searching key words and cycle through each result one by one using up or down keys

How can I achieve that?

2

This, from man bash:

   HISTFILE
          The name of the file in which command history is saved (see HISTORY below).  The default  value  is
          ~/.bash_history.  If unset, the command history is not saved when a shell exits.
   HISTFILESIZE
          The maximum number of lines contained in the history file.  When this variable is assigned a value,
          the history file is truncated, if necessary, to contain no more than that number of lines by remov‐
          ing  the  oldest  entries.  The history file is also truncated to this size after writing it when a
          shell exits.  If the value is 0, the history file is truncated to zero  size.   Non-numeric  values
          and  numeric  values  less  than  zero inhibit truncation.  The shell sets the default value to the
          value of HISTSIZE after reading any startup files.
  • Thank you for your answer. I didn't know that trick, I can use it as a last resort. But I thought of some awk, grep, sed etc. functions triggered by up or down keys. – kenn Jan 9 at 10:07

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.