Skip to content

Fix nvim-remote commands for fish shell #4506

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

SavingFrame
Copy link

Fish shell does not support "&&" and "||" operators like POSIX-compatible shells. Instead, it uses a different syntax structure based on begin/end and if/else.

This caused existing lazygit nvim-remote integration templates to break when fish was the user's default shell.

This commit adds explicit fish shell detection using the FISH_VERSION environment variable, and provides fish-compatible templates that correctly handle launching Neovim or sending remote commands via $NVIM.

Fixes behavior where edits would not open in a new Neovim tab or line navigation would fail when $NVIM was set.

Ensures smoother editing experience for users running fish shell (supported since Nov 2012 with FISH_VERSION).

  • PR Description

  • Please check if the PR fulfills these requirements

  • Cheatsheets are up-to-date (run go generate ./...)
  • Code has been formatted (see here)
  • Tests have been added/updated (see here for the integration test guide)
  • Text is internationalised (see here)
  • If a new UserConfig entry was added, make sure it can be hot-reloaded (see here)
  • Docs have been updated if necessary
  • You've read through your own file changes for silly mistakes etc

SavingFrame and others added 3 commits April 23, 2025 12:24
Fish shell does not support "&&" and "||" operators like
POSIX-compatible shells. Instead, it uses a different syntax structure
based on begin/end and if/else.

This caused existing lazygit nvim-remote integration templates to break
when fish was the user's default shell.

This commit adds explicit fish shell detection using the FISH_VERSION
environment variable, and provides fish-compatible templates that
correctly handle launching Neovim or sending remote commands via $NVIM.

Fixes behavior where edits would not open in a new Neovim tab or line
navigation would fail when $NVIM was set.

Ensures smoother editing experience for users running fish shell
(supported since Nov 2012 with FISH_VERSION).
Pass shell into getPreset instead of using the SHELL env variable.
More specific variable names.
@stefanhaller stefanhaller added the bug Something isn't working label Apr 23, 2025
@stefanhaller
Copy link
Collaborator

Thanks for fixing this! It also came up here, and my suggestion for fixing it was to not use the users shell when calling editor commands, but always using bash as we did before. But your fix may be the better one, as it allows users to use aliases or custom paths for their editors, which came up as a request once or twice.

I pushed two fixups: one is to use same logic to decide which shell to use as the code that eventually calls the command (dc0e1a6); the other is to use more specific variable names (9a77469).

I'll let @jesseduffield decide if he's happy with the approach used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants