-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Save REPL history to file .dotty_history in home directory #5252
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello, and thank you for opening this PR! 🎉
All contributors have signed the CLA, thank you! ❤️
Have an awesome day! ☀️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks @nrjais
.terminal(terminal) | ||
.history(history) | ||
.completer(completer) | ||
.highlighter(new Highlighter) | ||
.parser(new Parser) | ||
.variable(HISTORY_FILE, s"$userHome/.dotty_history") // Save history to file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this work on Windows or do we need File.pathSeparator instead of / here too ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This goes through java.nio.file.Paths
. I believe it handles path separator correctly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. Note for later: To be perfect we probably shouldn't write files directly in the home directory, on Linux you should use $HOME/.config/nameofyourapplication/ and on Windows there's some other folder, but this is hard to handle correctly. There's https://github.com/soc/directories-jvm that is designed to do that for you, but it doesn't seem to have a stable ABI so we'd have to embed it in our sources.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think $HOME/.dotty_history
is the right place on Linux. A history file isn't a configuration file, so it doesn't belong under $HOME/.config
. Also cp. $HOME/.scala_history
, $HOME/.histfile
, $HOME/.bash_history
and many, many more ...
For configuration files on Linux, if you're going to bother with the XDG spec, you should first check if $XDG_CONFIG_HOME
is set and only default to $HOME/.config
if it isn't. But bear in mind that standards schmandards and lots of configuration stuff still quite happily lives in dotfiles directly in $HOME
.
Fixes #5142