5

zsh has a great feature of autosuggestion (through a plugin) which remembers as one type in the terminal and then helps out during next instance of typing the same command.

I have around 1000 lines of commands stored in a notepad which will be useful for all my projects.

Is there a way that I can manually add all these 1000 lines of commands to zsh autosuggestion feature without typing it for the first time?

2
2
  1. Make sure you've configured Zsh to keep enough history entries. On the command line, do
    echo $HISTSIZE $SAVEHIST
    
    • If the numbers reported are well above 1000, then you're fine. If not, add the following to your .zshrc:
      HISTSIZE=20000
      SAVEHIST=10000
      
  2. Find out what the location of your history file is, by doing
    echo $HISTFILE
    
  3. In your histfile, look what the beginning of the first line says. In my case, for example (!), it says
    : 1584024476:0;cd /usr/local/share/zsh/functions/zkbd
    
  4. Copy the beginning of the line up to and including the ;. (Do not copy the timestamp above! Copy the one you find in your own histfile.)
  5. Paste this part in front of every command that you have stored in your notepad.
  6. Close your terminal.
  7. Paste in your entire notepad at the top of your histfile.
  8. Reopen your terminal.

Done! If you're using the history strategy of zsh-suggestions, then the lines you copy-pasted should now be automatically offered as suggestions.

2
  • Took out your time and bingo the answer. – Praveen Kumar-M May 23 '20 at 4:17
  • 1
    Yes, my timestamp was only an example. 🙂 – Marlon Richert May 23 '20 at 6:54

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.