OS X, Bash, 0.8.1
export EDITOR=vim
(or another editor).cmd+,
to open preferences.~/.hyper.js
will have opened with nano
.I expected ~/.hyper.js
to be opened with $EDITOR
, in this case vim
.
~/.hyper.js
was opened with nano
.
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:
I am happy to submit a PR once a potential solution has been agreed on. Thanks for your hard work!
same here
Not related to the issue, but wanted to say you have a beautiful prompt and color scheme 馃憤
Might just be me saying weird things.. but isn't export EDITOR=vim
heavily related to your current shell session. cmd+,
opens a new tab, which is a new shell session with a different pid 馃槄
@zpnk you're right, single quote bash strings don't expand the variable.
> echo ${EDITOR}
nvim
>echo '${EDITOR}'
${EDITOR}
>echo "${EDITOR}"
nvim
@albinekb in #575 you said your changed worked in bash
. Did you confirm that the correct editor was opened?
Well, at least it opens for you!
echo Attempting to open ~/.hyper.js with your $EDITOR
echo If it fails, open it manually with your favorite editor!
bash -c 'exec env ${EDITOR:=nano} ~/.hyper.js'
~$ echo Attempting to open ~/.hyper.js with your $EDITOR
Attempting to open /Users/ojf/.hyper.js with your vim
~$
This is probably a side-note, but possibly part of the problem - I'm pretty sure that should be :-nano
above; not :=nano
. The latter will actually assign 'nano'
to $EDITOR
, while the former will just use it.
and the default nano color scheme is something wrong at nano - see #838
Works as expected for opening vscode when I've added:
export EDITOR=code
to my .bash_profile
Hyper runs bash -c 'exec env ${EDITOR:=nano} ~/.hyper.js'
in a new tab so if you set $EDITOR
in one tab the environment variable doesn't exist in the one Hyper actually executes the command in unless it's set in .bash_profile
and as such export
does nothing because the subshell run by bash -c
never gets given the variable
@timneutkens just realised you reached this conclusion before me.
I can reproduce that behavior and I think it happens because bash does not evaluate .profile
/.bash_profile
when using -c
. Adding -l
forces a login shell and seems to do the trick.
@dak0rn is your $EDITOR
variable in .bash_profile
defined with or without export
?
It's defined with export
:
#!/bin/bash
source .bashrc
export EDITOR=vim
@dak0rn Possibly related https://github.com/zeit/hyper/issues/699
Weird
My .bashrc
is blank, and .bash_profile
just has
export EDITOR=code
Output:
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:
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.
Perhaps this could be a useful addition, just to make sure the edge case is covered? Are the any downsides to using -l
?
@zpnk Ah nice, so this ticket is kind of resolved by that. I agree that adding -l
would be a good thing. Since otherwise ~/.bash_profile
shouldn't be sourced.. which could lead to $EDITOR
not being set when opening the tab 馃 .. on second thought... this should just function right away.. since $EDITOR
is set by opening the new tab (when a new to is opened --login
is added to the command automagically. see #699). Still have a feeling fixing #699 might resolve all this.
_Do note I'm not a bash user (ZSH here) and this is all from a Hyper codebase point of view_ 馃槈
export EDITOR='whatever'
instead of EDITOR='whatever'
solved it for me
This website solved this problem for me (I am using oh-my-zsh): http://linuxg.net/how-to-change-the-default-editor-in-linux/
@roelvan Thanks! Solved adding export EDITOR=sublime -w
in ~/.zshrc
Looks like this issue can be closed.
I am still having this issue, opening sublime text for me when I have
export EDITOR=atom
in my .zshrc
This has been changed to use the system default editor which is controlled by your window manager (Gnome, KDE, .Cinnamon, etc.). You can probably change that in either your file manager or preferences application.
Thanks for your help @MartyGentillon.
Indeed, this issue is outdated.
Most helpful comment
export EDITOR='whatever'
instead ofEDITOR='whatever'
solved it for me