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

History in XDG_DATA_HOME, configurable via Environment variable #1421

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

eliminmax
Copy link
Contributor

I created a modified version of 0.12.8, then ported my changes to 0.12.9, that changes the history file path to have the following behavior:

If $HISTFILE_OIL/$HISTFILE_OSH environment variable for the current language is set, use that.
Otherwise, if $XDG_DATA_HOME is set, save to "$XDG_DATA_HOME"/oil/history_oil or "$XDG_DATA_HOME"/oil/history_osh.
If neither option is set, fall back to ~/.local/share/oil/history_oil or ~/.local/share/oil/history_osh.

@andychu
Copy link
Contributor

andychu commented Dec 6, 2022

Thanks for the PR! I assume you're want this because you don't want the history file in ~/.local/share?

Is XDG_DATA_HOME sufficient for your use case? If so then I would prefer to limit it to that (e.g. because more features means more things to document, and this isn't documented yet)

@eliminmax
Copy link
Contributor Author

eliminmax commented Dec 6, 2022

Exactly - I prefer to keep any history files in one directory (specifically ~/.local/share/histfiles). If you'd rather not include that functionality, that's fine.

@andychu
Copy link
Contributor

andychu commented Dec 7, 2022

OK sounds good, please remove the other env var and just use XDG_DATA_HOME

And revert the oil-version.txt change -- that is only for releases

Thank you

@andychu
Copy link
Contributor

andychu commented Dec 7, 2022

Hm actually it sounds like XDG_DATA_HOME isn't enough if you want ~/.local/share/histfiles ?

Setting that would mean a lot of other non-history data is stored there too

@eliminmax
Copy link
Contributor Author

Using this patch, set the HISTFILE_OSH and HISTFILE_OIL variables to point to ~/.local/share/histfiles/osh and ~/.local/share/histfiles/oil, respectively, and set similar variables or configuration options for other programs. That's why I wanted the other environment variables to be available as options.

@eliminmax
Copy link
Contributor Author

I noticed, once I installed my patched version on a bare-bones Linux From Scratch system I'd made, that if the directory of the history file is missing, regardless of what it is, it silently fails to save history, so I think my patch needs a bit more work anyway - will close for now, and reopen once I've finished my college finals and had a chance to fix that.

@eliminmax eliminmax closed this Dec 7, 2022
@andychu
Copy link
Contributor

andychu commented Dec 7, 2022

Hm what shell do you normally use, and how do you point it at your histfiles dir?

Hm looks like bash and zsh BOTH support the $HISTFILE env variable

https://linuxhint.com/check-zsh-history/

But does that mean bash and zsh overlap? I don't think they can actually read from the same file


I think there is something to do here, but I'm not sure what the right behavior is

@andychu andychu reopened this Dec 7, 2022
@eliminmax
Copy link
Contributor Author

eliminmax commented Dec 7, 2022

I usually use bash with $HISTFILE set to ~/.local/share/histfiles/bash in my .bashrc file. I think that because its set in the rc file and not exported, they avoid conflict

@andychu
Copy link
Contributor

andychu commented Dec 7, 2022

I think one thing we could do is have OSH support plain $HISTFILE and Oil support something else

@andychu
Copy link
Contributor

andychu commented May 18, 2023

Hi, I'm thinking about this again. I'm thinking of doing it like this:

  • OSH respects $HISTFILE , which is a POSIX variable, and default is ~/.config/oils/osh_history
  • YSH respects $HISTFILE_YSH , default is ~/.config/oils/ysh_history

We can do XDG_DATA_HOME later, but I wonder if that is enough for your use case ?

(Project was slightly renamed - https://www.oilshell.org/blog/2023/03/rename.html )

@andychu
Copy link
Contributor

andychu commented May 18, 2023

Although I guess ~/.local/share/oils/{osh,ysh}_history can be considered cleaner, since it's not config

bash and zsh put it in ~

Fish follows that style, so I think we can do that

ls ~/.local/share/fish/
fish_history  generated_completions/

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.

None yet

2 participants