Closed rburny closed 10 years ago
Hi, thanks for the suggestion, this would be an interesting feature.
Yes, tmux send-keys
can do this, but I see a few downsides:
history -w foo_file
and history -r foo_file
commands as if they were "typed" in the console.history -w foo_file
should not be run if a program (ie vim) is running in the pane. send-keys
can mess the programs' current state.Yes, I understand some people might find such feature intrusive or surprising. It should likely by flag-gated, so whoever enables the flag knows what he's doing.
Restricting save to panes not running any program could work based on #{pane_current_format}
value, which is already extracted from tmux. If user really needs to save "running" pane history, he can pause running program himself with Ctrl-z.
As for "dirtying" user state - I did some research and I think impact can be minimized:
history -w
command, it should be prefixed by space. With Bash's default HISTCONTROL setting, space-prefixed commands are not saved to history.history -r
is never saved to history, as it "overwrites itself". If combined with clear (history -r foo_file && clear
), it is never even seen by user, and newly started shell looks clean.As you can see, the only annoyance is visible history write, and the history itself is never clobbered.
The use case for such feature is as follows. I usually have a few panes open: one for editing, one for build/unit testing, others for deployment. If I need to restart machine, the most annoying part is to recall all the commands. Having tmux-resurrect restore windows & working dirs is great, but having history would make it perfect!
Flag-gating this makes sense. Ok, you got me convinced. If you can make this feature work (and it doesn't majorly screw up other things) submit a pull request and we'll "polish" the feature together and merge it.
Saving the history should probably be hooked at the end of this function. Restoring the history should go before this function.
Don't worry about flag-gating this or making the code nice - we can do that later.
I have pushed an implementation to my repo (see https://github.com/rburny/tmux-resurrect/commit/f69b64e994474fb66fe85612ac50333f1887071f)
This does not have flag-gating, but I think it's pretty complete otherwise. Should I open a pull request?
Hi, thank you for the work. No need to open a pull request - I'll cherry-pick your commit (you'll still be shown as a committer), test it and do the rest of the work.
@rburny, all looks good. Can you please check pull request #49 and see if you have any comments? If not, I think that one is ready for merging into master.
This was implemented in #49
Any chance this is similarly simple to do for zsh?
Please consider saving Bash history for each pane. This can be done relatively simply (on Bash side) by using following commands:
How to send these commands to each pane is a trickier question, but I believe tmux's
send-keys
functionality can achieve this - at least when no program is running in given pane.