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

Smarter handling of path for storing .omp.cache #1017

Closed
1 task done
ralish opened this issue Oct 3, 2021 · 3 comments
Closed
1 task done

Smarter handling of path for storing .omp.cache #1017

ralish opened this issue Oct 3, 2021 · 3 comments
Assignees
Labels
🚀 feat New feature

Comments

@ralish
Copy link
Contributor

ralish commented Oct 3, 2021

Code of Conduct

  • I agree to follow this project's Code of Conduct

What would you like to see changed/added?

PR #982 was merged recently (nice addition!) and as a result a .omp.cache file is stored in the user's home directory. That's fine on Unix-like systems, where it's not unusual for configuration files to be stored directly in $HOME (and they're hidden anyway). On Windows, configuration files are typically not stored directly under the user's home directory, nor are files or folders with a dot prefix hidden by default.

For those among us who like to keep their home directory tidy, the current behaviour of storing the cache file directly under the home directory isn't ideal. I'd suggest selecting the path to store the cache file a bit more intelligently based on the platform.

Windows
The "conventional" path would be something like $env:LOCALAPPDATA\oh-my-posh\.omp.cache, which expands to something like: C:\Users\user\AppData\Local\oh-my-posh\.omp.cache. The $env:LOCALAPPDATA path is intended for application data which is local to the system (i.e. does not roam with the user profile). Cache files are a perfect example of such data.

Unix-like
Less annoying perhaps, but it would be nice to conform to the XDG Base Directory Specification. This is pretty simple with the relevant part being:

$XDG_CACHE_HOME defines the base directory relative to which user-specific non-essential data files should be stored. If $XDG_CACHE_HOME is either not set or empty, a default equal to $HOME/.cache should be used.

So the ideal case would be something like $env:XDG_CACHE_HOME/oh-my-posh/.omp.cache, where $env:XDG_CACHE_HOME is $HOME/.cache if not set.

Anything else and/or failure cases
Fallback to the current approach :-)

@ralish
Copy link
Contributor Author

ralish commented Oct 3, 2021

Wow, unbelievably fast turnaround! Lgtm, with the only comment being that storing the cache in its own directory is I think slightly preferable, as it makes it unambiguous which application owns the file (i.e. $env:LOCALAPPDATA\oh-my-posh\whatever or $env:XDG_CACHE_PATH/oh-my-posh/whatever). That said, this is still a big improvement over the current setup!

@JanDeDobbeleer
Copy link
Owner

@ralish it creates that folder, so it should be OK

Copy link

github-actions bot commented Apr 1, 2024

This issue has been automatically locked since there has not been any recent activity (i.e. last half year) after it was closed. It helps our maintainers focus on the active issues.
If you have found a problem that seems similar, please open a discussion first, complete the body with all the details necessary to reproduce, and mention this issue as reference.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🚀 feat New feature
Projects
None yet
Development

No branches or pull requests

2 participants