Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 79 add option to add datetime to filename #80

Closed
wants to merge 4 commits into from

Conversation

joncrangle
Copy link
Contributor

Responds to issue: #79 .

The user can provide an optional date_fmt string in the strftime syntax interpreted by wezterm.strftime(). If this opt is provided, the current local datetime will be appended to the saved filename for the state and visible in the fuzzy picker when restoring or deleting it.

--- e.g.
     action = wezterm.action_callback(function(win, pane)
       resurrect.save_state(resurrect.workspace_state.get_workspace_state(), nil, "%Y-%m-%d %H:%M:%S")
     end),
---
     action = resurrect.window_state.save_window_action(nil, "%Y-%m-%d %H:%M:%S"),
---
     action = resurrect.tab_state.save_tab_action(nil, "%Y-%m-%d %H:%M:%S"),

I added the optional opt_name param to the save_window_action and save_tab_action functions to make them consistent with the resurrect.save_state args.

Copy link
Owner

@MLFlexer MLFlexer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like that it is done using Lua! Much better than using external processes like ls -l

minor comments about the args and code style

plugin/init.lua Outdated Show resolved Hide resolved
plugin/init.lua Outdated Show resolved Hide resolved
plugin/resurrect/tab_state.lua Outdated Show resolved Hide resolved
plugin/resurrect/window_state.lua Outdated Show resolved Hide resolved
joncrangle and others added 3 commits December 25, 2024 23:34
Co-authored-by: Malthe Larsen <75012728+MLFlexer@users.noreply.github.com>
use opts table for interacting with save_state
remove unnecessary initialization to empty strings
@MLFlexer
Copy link
Owner

I have been thinking about this PR and also reviewed #82 which tries to tackle the same issue.

I think that I will go with #82 because this PR will add a file each time the state is saved, i.e. when saving the state, it will add a new version of the state with the name <state_name> <date>. This can fill the state directories with a lot of versions of the same state, however I would think a user would only care about the newest version of the state. Thus making the older versions redundant.

Please correct me if I am wrong, but because of this reason, I think I will close this PR and merge #82 instead.
But again, thank you for taking the time trying to fix the issue! 😄

@joncrangle joncrangle closed this Jan 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants