Skip to content

shell: nushell integration scripts#4630

Open
sim590 wants to merge 129 commits into
junegunn:masterfrom
sim590:nushell-integration
Open

shell: nushell integration scripts#4630
sim590 wants to merge 129 commits into
junegunn:masterfrom
sim590:nushell-integration

Conversation

@sim590
Copy link
Copy Markdown

@sim590 sim590 commented Dec 9, 2025

  • Keybindings alt_c, ctrl_r and ctrl_t
  • Completion functions:
    • base implementation for ** completion
    • extra completion functionalities for programs such as:
      • pass
      • ssh, scp, sftp, telnet
      • kill
      • cd, pushd, rmdir

Closes: #4122

imsys and others added 30 commits May 4, 2025 04:58
Fixes some path issues. There are still some other things to fix
Pass~[1] is a command line password storage utility. Possible queries
are deduced from the file GPG hierarchy under ~/.password-store.

[1]: https://www.passwordstore.org/
Not sure why it doesn't work in this context, but if those are not
removed, the completion process doesn't substitute the selected value
to '**'.
fix typo  shell/key-bindinds.nu → shell/key-bindings.nu
Comment thread test/lib/common.rb Outdated
Comment thread shell/key-bindings.nu Outdated
Comment thread shell/completion.nu Outdated
sim590 and others added 8 commits May 4, 2026 12:34
Co-authored-by: Junegunn Choi <junegunn.c@gmail.com>
The _nu suffix is unnecessary since these functions are only loaded
in nushell. The only exception is __fzf_defaults_nu which keeps its
suffix to avoid conflicting with __fzf_defaults in key-bindings.nu.
Rename __fzf_defaults_nu to __fzf_defaults and align the
implementation with the identical function in key-bindings.nu,
as suggested by @junegunn.
Comment thread shell/completion.nu
sim590 added 2 commits May 6, 2026 12:37
Save the pre-fzf completer in $env.__fzf_previous_completer on first
load. On re-source, use that saved reference as the base instead of
the current completer (which is already the fzf wrapper), preventing
wrapper nesting while still allowing re-sourcing to take effect.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.

Comment thread shell/completion.nu
Comment thread install Outdated
Comment thread .github/workflows/linux.yml
@junegunn
Copy link
Copy Markdown
Owner

junegunn commented May 7, 2026

I'm not a nushell user so I might be missing something, but that the fuzzy completion is not always available is quite confusing to me. vim **<tab> works, ls **<tab> doesn't. kill **<tab> doesn't work, unless I change it to ^kill **<tab>. This is confusing, also a bit frustrating to see that fuzzy completion doesn't pop up only after I typed in **. Is there a way to make the situation better? Or is this a fundamental limitation of nushell?

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@sim590
Copy link
Copy Markdown
Author

sim590 commented May 7, 2026

These are fundamental limitations of Nushell's completion architecture:

  • ls **<TAB> / kill **<TAB> don't work because ls and kill are Nushell built-in commands. Since Nushell 0.103.0 (nushell/nushell#15086), the external completer is no longer invoked for internal commands. Using ^kill **<TAB> forces the external binary, which goes through our completer — that's why it works.

  • The ** trigger requirement exists because Nushell's external completer is only called "if no Nushell completions were found". For external commands (like vim, ^kill), Nushell has no built-in completions, so our completer gets called and can check for the trigger. The trigger is a deliberate design choice (same as bash/zsh) to avoid replacing the user's existing completions for every command unconditionally.

AFAIK, there's no way around these limitations without changes on the Nushell side.

sim590 added 3 commits May 10, 2026 18:18
…ushell

Like fish, the nushell block now checks $key_bindings and
$auto_completion. When both are enabled, fzf --nushell is used as
before. When only one is enabled, the relevant section is extracted
from fzf --nushell output via awk, embedding the content directly
rather than sourcing from an absolute path.
Rename the generated nushell autoload file to _fzf_integration.nu to
reduce the risk of overwriting a user's custom script. Also replace the
awk extraction with a direct cp of the relevant source file for the
partial key-bindings/completion cases.
junegunn
junegunn previously approved these changes May 13, 2026
Copy link
Copy Markdown
Owner

@junegunn junegunn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the persistence; it's good to go.

But I'll merge it right before I release a new version so the README doesn't mention unreleased features and confuse users.

@junegunn
Copy link
Copy Markdown
Owner

Ah, we also need to update

fzf/man/man1/fzf.1

Lines 1352 to 1369 in 263eb47

.SS SHELL INTEGRATION
.TP
.B "\-\-bash"
Print script to set up Bash shell integration
e.g. \fBeval "$(fzf \-\-bash)"\fR
.TP
.B "\-\-zsh"
Print script to set up Zsh shell integration
e.g. \fBsource <(fzf \-\-zsh)\fR
.TP
.B "\-\-fish"
Print script to set up Fish shell integration
e.g. \fBfzf \-\-fish | source\fR

@sim590
Copy link
Copy Markdown
Author

sim590 commented May 13, 2026

Ah, we also need to update

fzf/man/man1/fzf.1

Lines 1352 to 1369 in 263eb47

.SS SHELL INTEGRATION
.TP
.B "\-\-bash"
Print script to set up Bash shell integration
e.g. \fBeval "$(fzf \-\-bash)"\fR
.TP
.B "\-\-zsh"
Print script to set up Zsh shell integration
e.g. \fBsource <(fzf \-\-zsh)\fR
.TP
.B "\-\-fish"
Print script to set up Fish shell integration
e.g. \fBfzf \-\-fish | source\fR

Did it in 52a23e3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci CI/GitHub Actions docs Documentation go Go code install Install/uninstall scripts shell Shell scripts test Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request] nushell integration

6 participants