GithubHelp home page GithubHelp logo

Comments (8)

unphased avatar unphased commented on August 17, 2024 5

Any chance this is similarly simple to do for zsh?

from tmux-resurrect.

bruno- avatar bruno- commented on August 17, 2024

Hi, thanks for the suggestion, this would be an interesting feature.

Yes, tmux send-keys can do this, but I see a few downsides:

  • all panes would get "dirty" on each save and each restore. What this means is: a user would see the history -w foo_file and history -r foo_file commands as if they were "typed" in the console.
  • as you mentioned, save would not be possible when another program is running in a pane
  • when saving, the 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.

from tmux-resurrect.

rburny avatar rburny commented on August 17, 2024

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:

  • when issuing 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!

from tmux-resurrect.

bruno- avatar bruno- commented on August 17, 2024

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.

from tmux-resurrect.

rburny avatar rburny commented on August 17, 2024

I have pushed an implementation to my repo (see rburny@f69b64e)

This does not have flag-gating, but I think it's pretty complete otherwise. Should I open a pull request?

from tmux-resurrect.

bruno- avatar bruno- commented on August 17, 2024

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.

from tmux-resurrect.

bruno- avatar bruno- commented on August 17, 2024

@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.

from tmux-resurrect.

bruno- avatar bruno- commented on August 17, 2024

This was implemented in #49

from tmux-resurrect.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.