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

[stored] automatically save input history by default #2298

Closed
midichef opened this issue Feb 5, 2024 · 5 comments
Closed

[stored] automatically save input history by default #2298

midichef opened this issue Feb 5, 2024 · 5 comments

Comments

@midichef
Copy link
Contributor

midichef commented Feb 5, 2024

Small description
if visidata_dir does not exist, input history does not persist between vd sessions: vd --visidata-dir=nonexistent

Expected result
I expect the directory to be created automatically, and the history to be saved to a file in it.

Actual result with screenshot
visidata_dir is not created.

However, not creating it, is consistent with the behavior of macros.py in the same situation. It only gives a warning and does not create the directory.

vd.fail(f'create {vd.options.visidata_dir} to save macros')

Additional context
visidata v3.1dev

If we were going to create the directory, this seems to be the place to do it:

if vdpath.exists():

@midichef midichef added the bug label Feb 5, 2024
@anjakefala
Copy link
Collaborator

Thanks for opening an issue! I'm planning to open a Discussion topic this week on people's preferred approaches. We wanted to see how other terminal tools also handled this. (Some users can be concerned about unexpected file creation outside of .cache or /tmp.)

@saulpw
Copy link
Owner

saulpw commented Feb 7, 2024

Hey @midichef, thanks for bringing this up. As @anjakefala mentioned, I've been hesitant to create a .visidata directory by default, and it looks like setup.py and other installation methods can't create files outside of the package directory, so we can't have distro packages make the choice and set it up for us. Currently, as you've noticed, the input history feature is gated on this directory existing (whereas previously it required an option to be set in .visidatarc).

We have a few options:

  1. Revert to requiring options.input_history to be set; we could maybe create a .visidata directory if that option is set and the directory doesn't exist.
  2. Document that the way to enable this feature, is simply to create the .visidata directory;
  3. Always create the .visidata directory, letting go of our policy of not writing to the filesystem by default. (I think @geekscrapy or @sfranky might have a preference against this?)

Which of these seems reasonable? Are there other options we could consider?

@geekscrapy
Copy link
Contributor

My 2 cents!

  • creating the .visidata dir by default is fine, as long as either it is in the users home, or wherever the user has explicitly set. This way permissions around the files are controlled and can be predicted
  • another option would allow the input history option to take a absolute path on its own (if it doesn't already which I think it does), otherwise it should be documented that it is relative to the users home dir (or .visidata dir, or something else that makes sense)
  • bash stores history by default, visidata could too

@sfranky
Copy link
Contributor

sfranky commented Feb 7, 2024

I heard my name, was it by accident, or was i following the issue? :P
I like all options !!

@saulpw saulpw changed the title [stored] input history is not saved if visidata_dir does not exist [stored] automatically save input history by default May 24, 2024
@saulpw saulpw removed the bug label May 24, 2024
@saulpw
Copy link
Owner

saulpw commented May 24, 2024

Okay, I've pushed this change, hopefully it makes it nicer for new users. The -N CLI flag should prevent it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants