Add --key flag to navi widget for custom keybindings#1024
Open
knpwrs wants to merge 1 commit into
Open
Conversation
Shell widget scripts now use template placeholders that are populated at runtime with either the default keybinding or a user-provided value via `navi widget <shell> --key <binding>`.
denisidoro
approved these changes
Apr 14, 2026
Collaborator
|
Hi, just to let you know that I'll check the PR tomorrow. Sorry for the long wait. |
Author
|
No problem. I'm working around it in my dotfiles for the time being: https://github.com/knpwrs/dotfiles/blob/441c9621777b1914553a59d498554e9887e47527/lib/navi.zsh |
Collaborator
|
Since there has been some PRs with helpful features merged, I'm planning to try and test it before making a (pre-release/release) version out of it. It will help on the side of debian's packaging since the new version removes dependencies and adds some useful features and bug fixes. I don't really know for now, I'll make a decision tomorrow after thinking about it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
--keyflag tonavi widgetso users can customize the keybinding without manually editing widget output__NAVI_KEY__) that are populated at runtime with the default or user-provided valueUsage
Without
--key, behavior is unchanged (defaults toCtrl+Gfor most shells,Alt+Hfor elvish).Context
Related to #837 — while that issue is about zellij support, it touches on the broader need to customize how navi integrates with different terminal environments.
Ctrl+Gis the default unlock for zellij.The widget docs previously stated: "There's currently no way to customize the widget behavior out-of-the-box" — this text was added by the project creator in PR #480 (commit a8ddc13, April 2021). The PR body and comments are empty, and I couldn't find any related issues or discussion suggesting this was a deliberate design constraint rather than simply the state of things at the time.
Alternative approach
The same effect can be achieved today by rebinding after eval. For example in zsh:
This works because the widget's
evalregisters the_navi_widgetfunction and zle widget — the subsequentbindkeycalls just reassign the trigger key. The--keyflag makes this a one-liner instead.So as an alternative to this PR we can also update the docs.
Test plan
navi widget zshoutputsbindkey '^g'(default preserved)navi widget zsh --key '^ 'outputsbindkey '^ 'navi widget bash --key '\C- 'replaces both legacy and modern bind linesnavi widget fish --key '\c 'replaces both normal and insert-mode bindsnavi widget nushell --key 'control:char_space'replaces modifier and keycodenavi widget powershell --key 'Ctrl+Space'replaces Chord valuenavi widget elvish --key 'Ctrl-g'replaces binding key__NAVI_KEY__placeholders leak in any shell's default outputcargo testpasses