-
Notifications
You must be signed in to change notification settings - Fork 810
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
can't change editor via env vars #589
Comments
Hi, @caleb15
It looks like you didn't export your envvar. Try: export EDITOR=code You can also do this all inline: EDITOR=code cheat-e tree Setting |
@chrisallenlane I did export my env var, as you can see in the output I posted. I forgot to export the var the first time but remembered to do it later on, yet it still didn't work. |
Oh, I see. Sorry - I saw that first line and jumped to a conclusion. A bit of experimentation on my machine suggests that this may in fact be broken. I'll take a look at it over the next few days, and will update this ticket when I have more information. |
OK - I see what's happening. There's no "bug" here, in that this is working as intended. That said, I'm not sure that the way it's intended to work is actually sensible. Here's the relevant code: if conf.Editor == "" {
if os.Getenv("VISUAL") != "" {
conf.Editor = os.Getenv("VISUAL")
} else if os.Getenv("EDITOR") != "" {
conf.Editor = os.Getenv("EDITOR")
} else {
return Config{}, fmt.Errorf("no editor set")
}
} The logic is that envvars will be respected if and only if you do not have an I'm not sure how I feel about this. On one hand, it makes sense: it's necessary that you provide a config file, and it seems sensible that the values therein should be respected. I think an argument could be made that these envvars shouldn't be respected at all, and that it be required that all configs should be made via the config file. On the other hand, given that envvars currently are respected, it's counter-intuitive that the following does not work: EDITOR=nano cheat -e foo (I personally expected the above to work, and was surprised when it did not.) I guess that leaves us with a few options:
I'm not sure which I prefer, personally, though 3 has the (significant) advantage of being backwards-compatible. Do you have an opinion, @caleb15? I'm going to leave this issue open for a while to gather input regarding how to proceed. In the meantime, yeah - set your |
I have a similar enough problem. I installed
I verified with I will try to investigate the problem myself, but I am a go novice, so not sure I can help much.
|
Hey @Honeypot95 - the snap version has this config file: Nano and vim are packaged together within the cheat snap, so these are the only two options to choose from. If you need a different editor you should install the cheat binary directly. |
For the 3 options in @chrisallenlane 's comment, I would say making the envVar override the config option would make the most sense. $EDITOR is understood by many programs besides cheat, so it's something of an expected custom |
I'll just put in my 2 cents. I disagree with @tculp - I think it should default to Furthermore, I think 'deprecating envvars' is not a nice way to go. Envvars is a pretty basic thing on a Linux system and should, in my opinion, be respected. In that vain, under Thank you for a brilliant application! |
I don't have a dog in the fight of whether the config should override EDITOR or vice versa. I just installed cheat today. The thing that tripped me up was just that the generated config file sets the editor to vim. I had EDITOR set to nvim and no vim installed, so this was very confusing. Imo, the editor setting in the default conf.yml should be commented out. I think that would neatly sidestep this issue for newcomers. |
Thanks for submitting a bug report. Please provide the following information:
A description of the problem
I'm not able to change the editor cheat uses via env vars
cheat version info
4.0.4
From the comment here it looks like it should be supported, or at least it used to be in the past.
As a workaround I was able to change the editor by changing
~/.config/cheat/conf.yml
The text was updated successfully, but these errors were encountered: