Kitty: Opening preferences uses vim even though $EDITOR is set to nvim

Created on 27 May 2018  路  12Comments  路  Source: kovidgoyal/kitty

I've installed kitty via Homebrew. kitty --version result in kitty 0.10.1 created by Kovid Goyal. Running echo $EDITOR result in nvim. Running echo $- result in himBCHs, i.e., an interactive shell. Pressing super+, inside kitty opens a new os window with vim open, not nvim, as I would expected.

It seems like kitty is using the EDITOR environment variable here: https://github.com/kovidgoyal/kitty/blob/master/kitty/constants.py#L19.

I'm not quite sure what's going on. I'd glad to help in any way possible.

Cheers,
Kevin

Most helpful comment

All 12 comments

It looks like kitty gets the environment variables before any shell has loaded, so setting $EDITOR inside the .profile file in your home directory, then logging in and out will get it to use the correct editor

You need to set the environment variable in the environment in which kitty runs, not the shell. That means a system wide environment variable. How you do that is OS and distribution specific, but if you cannot fiure it out you can simply create a wrapper script to run kitty that sets the env var and then runs kitty.

@kovidgoyal makes sense. Thanks a lot for giving me the kitty.conf setting. Appreciate it! 馃憤

I have set editor nvim in my kitty.conf but it still opens vim on cmd+,. Any idea why?

Maybe nvim is not in your systemwide PATH.
Find out where the nvim executable is with type nvim, then change your kitty shell by setting the option in kitty.conf:
shell python3 -c 'import os; print(os.environ["PATH"]); input("Press Enter to quit...")'
and restart kitty.
WARNING: kitty will become pretty much useless until you remove/uncomment that config option again, so you'll have to edit that file with something else later.
Hopefully the python3 executable is in your PATH. If not, just use the absolute path to it.
This will print the PATH as kitty sees it, before any shell is started. Now check if the path you got from type nvim (I mean the directory, without the nvim part at the end) was printed. If it is then I have no idea why it's not working but if it isn't then use the output from type nvim in the editor config option.

@katsika

I was trying to use ed(1) on macOS and having similar issue. It seems like on macOS (Mojave) /etc/profile is not run when kitty opens the preferences editor and so even setting as system-wide $EDITOR in /etc/profile has no effect.

Verified by modifying kitty.conf with shell python -c 'import os; print(os.environ); input("Press Enter to quit...")' which shows that there is no $EDITOR environmental variable set.

Anyway, here is my most elegant work around to force an interactive login-shell

editor sh -cil '$EDITOR $0'

cc: @Luflosi

/etc/profile is sourced only inside shells, not graphical programs like
kitty. You need to set the environment variable system wide. How to do
that varies from macOS version to version. Or just use the editor option in
kitty.conf if convincing macOS to co-operate is too much hassle.

@sterpe @kovidgoyal just made commit 50e7351c73c08b4fe3937f02fc6b52e66987b673, which should allow you to set the EDITOR environment variable in your /etc/profile or other rc file and have kitty respect it if you leave the editor setting at the default value.

Sounds good. FWIW, I realized a simpler way on macOS is just to modify kitty.conf with

editor sh -cil "$EDITOR $0"

Which then tricks kitty to run (as editor) the interactive login-shell with string command of $EDITOR $0 and these seems similar in effect to 50e7351, if I understand correctly.

Kevin,

How do I set the tab stop when in bash shell (.vimrc) as in editing yaml (.yml) files. In native bash on rhel and osx I can edit ~/.vimrc and append

autocmd FileType yaml setlocal ai ts=2 sw=2 et

What is the equivalent in kitty?

Thank you!
jd

There are ANSI control codes to set terminal tabstops that work on all
terminals. A bit of googling will find them for you.
But if you want to change the tabstops when editing filesthe
place to do it is in the editor config, not the terminal config.

On Thu, Sep 05, 2019 at 05:08:05PM -0700, John Duffus wrote:

Kevin,

How do I set the tab stop when in bash shell (.vimrc) as in editing yaml (.yml) files. In native bash on rhel and osx I can edit ~/.vimrc and append

autocmd FileType yaml setlocal ai ts=2 sw=2 et

What is the equivalent in kitty?

Thank you!
jd

--
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub:
https://github.com/kovidgoyal/kitty/issues/580#issuecomment-528653975

--


Dr. Kovid Goyal
https://www.kovidgoyal.net
https://calibre-ebook.com


Was this page helpful?
0 / 5 - 0 ratings

Related issues

RedBeard0531 picture RedBeard0531  路  4Comments

wavexx picture wavexx  路  3Comments

hujianxin picture hujianxin  路  3Comments

bewzaalex picture bewzaalex  路  3Comments

metalelf0 picture metalelf0  路  4Comments