In my fish function, I'm evaluating constructed commandline via
eval (commandline), specifically - I'm looking for some file name from fzf, and then analyze if commandline was prepended with vim. If it was - instead of returning vim filename to press enter afterwards, I just evaluate it, as I showed before.
The thing is that if I evaluate it, instead of pressing enter manually, it is not going to history - e.g. I can not see it as previous command by pressing up.
I tried set -x history (commandline) $history after eval, but it shows me an error set: Tried to change the read-only variable “history”
Is there a way to manually add custom string (in my case commandline buffer) to history? thx.
history --mergedoes not merge history in chronological order #2312. So even if we manually add the command to~/.config/fish/fish_historywe will no be able to simply press up to see it (although you will get to it eventually if you press up enough).To get around this we can make a copy of
fish_historythen callbuiltin history --clearwhich will clear both fish's internal history and the history file. We then restore the history file from our copy, append our command and callhistory --mergeto merge the history file with the now empty internal history.