FreeBSD sh: is it possible to import a list of commands into fc without executing them?
4
votes
0
answers
166
views
I cannot find any indication that sh supports persistent history. So I am trying to create this functionality manually. At the end of my .shrc history I have added this:
trap -- 'fc -ln -- 1 >> "$HOME/.sh_history"' EXIT
This ensures that every time I exit the shell that the commands I have entered in that session are not lost in wind.
Now that I have the saving history bit sorted out, I am wanting to import all commands in
~/.sh_history
into fc upon logging in so that I can call commands from previous shell sessions.
I realize that it won't be quite as simple as this because I will have to find a way to make sure that I only append new commands to the end of ~.sh_history
, but I am confident I can hack it out provided that it is even possible to give a list of commands to fc without executing them.
Asked by Harold Fischer
(1974 rep)
Jul 2, 2018, 01:14 AM