hyper: $EDITOR is ignored when opening preferences in bash.

Platform / Shell / Hyper version

OS X, Bash, 0.8.1

Steps to reproduce

  1. Open Hyper with a bash session.
  2. Set export EDITOR=vim (or another editor).
  3. Hit cmd+, to open preferences.
  4. ~/.hyper.js will have opened with nano.

What I expected

I expected ~/.hyper.js to be opened with $EDITOR, in this case vim.

What happened instead

~/.hyper.js was opened with nano.

GIF

example

Details

The editor fallback was added in #517. At that point, the opening command looked like: bash -c "exec env ${EDITOR:=nano} ~/.hyper.js"' (src)

In #575, the double quotes were switched to single quotes, with the command becoming: bash -c 'exec env ${EDITOR:=nano} ~/.hyper.js' (src)

If those two commands are run directly in bash, only the one with double quotes respects the $EDITOR.

Two questions:

  1. Can anyone else reproduce this?
  2. If yes, what is the best approach to fix (keeping in mind cross-shell compatibility)?

I am happy to submit a PR once a potential solution has been agreed on. Thanks for your hard work!

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 21 (9 by maintainers)

Most upvoted comments

export EDITOR='whatever' instead of EDITOR='whatever' solved it for me

Not related to the issue, but wanted to say you have a beautiful prompt and color scheme 👍

I am still having this issue, opening sublime text for me when I have

export EDITOR=atom

in my .zshrc

This website solved this problem for me (I am using oh-my-zsh): http://linuxg.net/how-to-change-the-default-editor-in-linux/

Hey @timneutkens @robodair - sorry for the confusion regarding the reproduction steps. Thanks for explaining the differences in having $EDITOR set in .bash_profile vs just in the current shell session.

I’ve been testing with $EDITOR set via my .bash_profile, however today I discovered that it was only setting EDITOR=vim without an export. Shame on me!

Setting export EDITOR=vim in .bash_profile works for me:

screen shot 2016-10-11 at 1 01 47 pm

Although this doesn’t explain @dak0rn’s experience.

Adding the -l flag does work either way, as long as $EDITOR is somehow set in the profile it will still work.

screen shot 2016-10-11 at 1 01 09 pm

Perhaps this could be a useful addition, just to make sure the edge case is covered? Are the any downsides to using -l?

It’s defined with export:

#!/bin/bash
source .bashrc
export EDITOR=vim