Fóruns: ヘルプ (Thread #41289)

Separate history between instances (2019-10-03 17:22 by ninewise #83656)

Is there a way to separate history between instances?

I'm really used to executing the previous command (in the current shell) with up+enter, but yash inserts commands from other instances here.

I'm thinking I could set a different HISTFILE per instance (with mktemp) in the RC, and trap some sort of `history merge` on exit. Maybe someone already wrote this merge?

Responder a #83656×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Login

Re: Separate history between instances (2019-10-16 21:17 by ninewise #83704)

Reply To Message #83656
> I'm thinking I could set a different HISTFILE per instance (with mktemp) in the RC, and trap some sort of `history merge` on exit. Maybe someone already wrote this merge?

I've solved this by merging in a "stupid" way: in my RC I have:

HISTFILE=
HISTSIZE=5000
HISTRMDUP=5000
history -r .yash_history
trap 'h=$(mktemp) && history -w $h && history -c && history -r .yash_history && history -r $h && history -w .yash_history && rm $h' EXIT

This will "merge" the history on closing the shell. This does result in having a simplified history file, not the default fanciness - but for now this hasn't troubled me. Should someone have a "smart" merge, I'd still be interested, though.
Responder a #83656

Responder a #83704×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Login