bash question: how to get it to append to history file immediately, w/o automatically making those commands propagated to all running shell instances?
`PS0='$(history -a)'` kinda does it, but it doesn't move "already appended" pointer, so every time it writes all commands from the current session.
`PS0='$(history -a; history -c; history -r)'` (or other variations that include `history -r`) would avoid duplicating commands, but would also add to history commands from other shell instances.
Ah, `$(history -a)` runs in a subshell, so that value is never reset in the main shell process. The way to go is
```sh
declare -a PROMPT_COMMAND
PROMPT_COMMAND+=("history -a")
```
Unlike PS0, it would write history only after the command has finished, but I can live with that.