I work in a place that has gazillions of tools which require tons of options, so I rely on my shell’s history significantly. I even back it up every now and then just to make sure I don’t lose useful, lengthy commands.
I just typed one of these commands and I want to make sure it’s flushed to the history file, but I have a long-running job in the background and I can’t type exec zsh. Is there something else I can do in this situation?
(Sure, I could copy and paste it into a file, but it would be more logical for there to exist a flush-history command.)
To write the shell history to the history file, do
fchas some useful flags, see them all inman zshbuiltins.You can also fully automate reading and writing the history file after each command (thus sharing your history file automatically with each running zsh) by saying
setopt -o sharehistory. Read more history-related options inman zshoptions.