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

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

Comments

Projects
None yet
2 participants
@dag
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

This comment has been minimized.

Show comment
Hide comment
@ridiculousfish

ridiculousfish Jan 24, 2013

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
Member

ridiculousfish commented Jan 24, 2013

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

This comment has been minimized.

Show comment
Hide comment
@ridiculousfish

ridiculousfish Jan 24, 2013

Member

Thanks for reporting this

Member

ridiculousfish commented Jan 24, 2013

Thanks for reporting this

@dag

This comment has been minimized.

Show comment
Hide comment
@dag

dag Jan 24, 2013

Contributor

It works, thanks!

Contributor

dag commented Jan 24, 2013

It works, thanks!

@dag

This comment has been minimized.

Show comment
Hide comment
@dag

dag Jan 24, 2013

Contributor

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.

Contributor

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

This comment has been minimized.

Show comment
Hide comment
@dag

dag Jan 24, 2013

Contributor

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?

Contributor

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

This comment has been minimized.

Show comment
Hide comment
@ridiculousfish

ridiculousfish Jan 24, 2013

Member

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

Member

ridiculousfish commented Jan 24, 2013

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

@dag

This comment has been minimized.

Show comment
Hide comment
@dag

dag Jan 24, 2013

Contributor

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

Contributor

dag commented Jan 24, 2013

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

@ridiculousfish

This comment has been minimized.

Show comment
Hide comment
@ridiculousfish

ridiculousfish Jan 24, 2013

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'
Member

ridiculousfish commented Jan 24, 2013

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

This comment has been minimized.

Show comment
Hide comment
@dag

dag Jan 24, 2013

Contributor

Yep it works, thanks again!

Contributor

dag commented Jan 24, 2013

Yep it works, thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment