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

How to set $EDITOR to something including arguments? #541

Closed
dag opened this issue Jan 23, 2013 · 9 comments
Closed

How to set $EDITOR to something including arguments? #541

dag opened this issue Jan 23, 2013 · 9 comments
Milestone

Comments

@dag
Copy link
Contributor

dag commented Jan 23, 2013

Trying to configure fish for using GVim for funced:

If I set EDITOR gvim, it starts in the background which doesn't work right. If I set EDITOR gvim -f it starts the built in interactive editor. Same thing if I do set EDITOR "gvim -f". If I write a function for running gvim -f and set EDITOR to that function, same thing.

It seems the only way to do this is to write a separate shell script?

@ridiculousfish
Copy link
Member

We were running type -f "$editor". Since there's no command 'gvim -f', this was failing.

Should be fixed here: debfc0f . Now we run type -f "$editor[1]", so you would write this:

set EDITOR gvim -f

@ridiculousfish
Copy link
Member

Thanks for reporting this

@dag
Copy link
Contributor Author

dag commented Jan 24, 2013

It works, thanks!

@dag
Copy link
Contributor Author

dag commented Jan 24, 2013

Alas, a new problem. If I now do set -x EDITOR gvim -f, it is exported as gvim:-f. I could probably work around this by exporting $VISUAL instead, but maybe it would be better to rename $EDITOR to something lower case, keeping with the convention of upper case variables being exported?

Note that for example, env EDITOR="gvim -f" git config --edit --global works fine; maybe fish should be consistent with how other programs interpret $EDITOR? Make it a single string, and tokenize it on whitespace for arguments. Kind of ugly, but seems to be what others do.

@dag
Copy link
Contributor Author

dag commented Jan 24, 2013

Actually I'm not sure what git is doing here, as it seems to accept even quoted arguments. Presumably it either includes a simple parser for this, or it is passing the string to a shell via -c or something. Maybe fish could simply eval?

@ridiculousfish
Copy link
Member

You're right...EDITOR should be exported without colons. So either it should not be an array, or it should be special cased.

@dag
Copy link
Contributor Author

dag commented Jan 24, 2013

(Re-open? I can't do it.)

@ridiculousfish
Copy link
Member

fish does just eval...the problem is that fish tries to protect you from yourself by checking whether the command is valid, and falling back to its own editor if it is not.

Try it now, with the new commit 5e9ca72 and no arrays, like so:

set -x EDITOR 'vim -f'

@dag
Copy link
Contributor Author

dag commented Jan 24, 2013

Yep it works, thanks again!

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

No branches or pull requests

2 participants