lazygit icon indicating copy to clipboard operation
lazygit copied to clipboard

using -ic instead of -c for command argument

Open shelper opened this issue 2 years ago • 10 comments

when i try to open a file in lazygit, i got an error: bash -c vim: vim cmmand not found i think the reason is i dont have vim installed, rather i have nvim and alias vim to nvim.

This becomes an issue when run vim through bash -c. as the alias is not correctly expanded.

I woudl suggest to change the option args from -c to -ic to avoid such issues.

shelper avatar Jan 26 '23 04:01 shelper

Can't you set $EDITOR to nvim?

mark2185 avatar Jan 26 '23 06:01 mark2185

i did that in .bashrc, i am in zsh calling bash -c, and does not work, i think due to the non-interactive call for bash...

shelper avatar Jan 26 '23 14:01 shelper

Makes sense.

There is a draft PR for precisely that feature, but it's somewhat stale and faulty.

Would you maybe be willing to pick it up? It's okay if you're not, just asking :)

In the meantime, you could just set the editCommand to nvim in your config - link to the docs.

mark2185 avatar Jan 26 '23 14:01 mark2185

i did that in .bashrc, i am in zsh calling bash -c, and does not work

You need to write export EDITOR="nvim" in your .zshrc.

Ryooooooga avatar Jan 27 '23 12:01 Ryooooooga

I believe I'm running into this as well.

brandonkboswell avatar Sep 28 '23 21:09 brandonkboswell

still not resolved i believe

shelper avatar Jan 30 '24 04:01 shelper

the problem is that nvim is invoked using bash, not zsh, thus, the nvim is a new instance in addition to the nvim that runs the laygit in its terminal.

shelper avatar Jan 30 '24 04:01 shelper

It seems from what you’ve described that the problem is your configs depending on shell specific behavior, aliases, to be called from other applications. This is incredibly brittle for the reasons you’ve discovered, and is best avoided for that reason. It has been suggested above that you either set $EDITOR or lazygit’s editCommand config as needed. Have you tried either of those? If so, is there a reason that neither of these have worked for you?

jwhitley avatar Jan 30 '24 05:01 jwhitley

yes, i have editor set to nvim, and have edit command set to either nvim or 'zsh -c nvim', none of that works... i am using lazyvim under zsh, and within lazyvim i call lazygit , and that is when it has problem, and the message when returning from lazygit says it uses bash -c nvim

shelper avatar Jan 30 '24 17:01 shelper

I was able to partially get it working by using the full nvim path.

I had the same issue where both the env variable and config were set correctly. None of that worked.

It still hangs and has to be killed if:

  1. you miss the filename.
  2. you attempt to use o for open on a file or a dir.
# .config/lazygit/config
os:
  edit: '/usr/local/bin/nvim-linux64/bin/nvim {{filename}}'

aaronjconway avatar Mar 19 '24 11:03 aaronjconway