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

Allow overriding config and cache dir by env var #6713

Closed
wants to merge 2 commits into from
Closed

Allow overriding config and cache dir by env var #6713

wants to merge 2 commits into from

Conversation

savente93
Copy link

Howdy folks. I wanted to add the ability to have my helix config behind a symlink for myself, then I saw the TODOs and figured I might as well kill two birds with one stone.

I would have added tests, but helix-loader doesn't seem to have any and I wasn't quite sure how to hook it into the current framework. It's a very small change so I think it's okay, but if anyone would like to see them added and is willing to help me for a few minutes I'm happy to add them.

If there's any additional requirements I wasn't aware of, please let me know.

cheers 👋

@savente93 savente93 changed the title Allow overdigin config and cache dir by env var Allow overriding config and cache dir by env var Apr 11, 2023
@archseer
Copy link
Member

Couldn't you just set the XDG_CONFIG_HOME and XDG_CACHE_HOME variables?

@savente93
Copy link
Author

I'm not familiar with those variables, though I believe you if you say Helix would obey them. I did look them up though and from what I understand that would mean that all applications would obey that which at least in my case is not what I want.

@the-mikedavis
Copy link
Member

Only if you set those variables globally. You can use them just for the helix command

XDG_CACHE_HOME=$HOME/tmp hx

or create a wrapper script for Helix that sets them somewhere custom:

#!/usr/bin/env bash
XDG_CACHE_HOME=/some/custom/cache/dir
/path/to/actual/binary/for/hx

Some packagers like nixpkgs use that strategy to adjust environment variables used by a package without polluting global environment variables

@savente93
Copy link
Author

okay that makes sense. Do you want me to close the PR? I don't really mind, but there were TODOs in the code about this so I don't know if someone else wanted this for some other reason? I still think this is a bit of a nicer solution, but I understand if you'd rather not add the extra code.

@the-mikedavis
Copy link
Member

Yeah I think this is not necessary. We also have the CLI flags for specifying the config and log files which I think would work as an alternative to the XDG environment variables too.

@savente93 savente93 closed this Apr 14, 2023
@linsui
Copy link

linsui commented Nov 15, 2023

I want this feature. :) It's much easier to set a env var than to add a wrapper.

@linsui
Copy link

linsui commented Nov 15, 2023

A problem mentioned in the matrix is that changing the XDG variables can affect programs invoked by helix, e.g. lsp.

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

4 participants