Repository navigation
Fix terminal modal mode for bash and fish via bell bindings - #114
Conversation
|
Can confirm this fix works for bash |
| if p.zdotDir != "" { | ||
| inputrc := filepath.Join(p.zdotDir, "inputrc") | ||
| if _, err := p.osStat(inputrc); err == nil { | ||
| cmd.Env = append(cmd.Env, "INPUTRC="+inputrc) |
There was a problem hiding this comment.
a bash terminal exports INPUTRC to all children, but a zsh terminal exports only ZDOTDIR, so running bash inside a Rune zsh terminal gets no bindings and modal mode breaks there.
Not sure what the best solution is here, maybe setting both env vars in both cases?
There was a problem hiding this comment.
My two cents:
Even though nested shells seems like an edge usage pattern, I don't see an issue with exporting both env vars.
I would add these tests:
- nested bash receives
INPUTRC; - nested zsh receives
ZDOTDIR;
| // readline does not fall back to ~/.inputrc when INPUTRC names a | ||
| // missing file, so only export one that exists. | ||
| if p.zdotDir != "" { | ||
| inputrc := filepath.Join(p.zdotDir, "inputrc") |
There was a problem hiding this comment.
If anyone sets the (undocumented) workspace.file.zdotdir in their .rune/config.yaml to their own zsh config dir, then p.zdotDir is set, but the inputrc will probably not be there, because it's only for bash, so users won't have an inputrc there.
I understand the motivation behind piggybacking off zdotdir, but I think we can cut a line and only use it to bundle and pass the inputrc file, and then have another field in the scheme for the location of inputrc.
|
New observed issue: adding
and also, runtime |
Modal mode only engaged under zsh. The vte synchronizes with the shell by writing ^A^G to the pty and waiting for the bell, but bash's vi-insert keymap self-inserts both bytes, and fish binds neither, so the handshake never completed and ^A^G showed up in the command line. For bash, ship an inputrc next to the bundled zsh dotfiles and export INPUTRC when the login shell is bash and the file exists; readline does not fall back to ~/.inputrc when INPUTRC names a missing file. The inputrc includes the system and user files first and binds ^A and ^G in every keymap under $if Bash, so runtime set -o vi works and other readline programs are unaffected. It is installed with the other zdot files and added to the Linux bundle. For fish, pass the bindings with --init-command when the shell starts with the default login arguments; they run after config.fish and survive fish_vi_key_bindings. The design and the inputrc come from unstablebuild#98. Hermetic tests cover INPUTRC and the fish arguments, and e2e tests drive bash and fish through a pty in modal mode. Signed-off-by: Eric Brooks <[email protected]>
…vi mode The vte homes the shell cursor with ^A and walks right with forward-char to reach the edit column, but readline clamps forward-char to the last character while its line editor is in vi mode. Appending at the end of the line therefore inserted one column short, so typing "echo hi" in modal mode produced "cho hie" under bash with set -o vi. Co-Authored-By: Rune Agent (claude/claude-opus-5-5) <[email protected]> Signed-off-by: ernestrc <[email protected]>
The zsh dotfiles and bash inputrc were copied out of the app bundle only on desktop launches, so dev builds, launches that pass --gui or --tui, and `rune -x` servers never exported ZDOTDIR or INPUTRC, and terminal modal mode broke in zsh and bash there. Co-Authored-By: Rune Agent (claude/claude-opus-5-5) <[email protected]> Signed-off-by: ernestrc <[email protected]>
zsh's viins keymap leaves the delete key unbound, and so does its emacs keymap unless the system zshrc binds it. The ESC [ 3 ~ that terminal modal mode sends to delete a character then left insert mode and ran vicmd's swap-case with a count of 3, so modal deletes in a zsh using bindkey -v upper-cased the command line. Rune's zsh dotfiles now bind it to delete-char. Co-Authored-By: Rune Agent (claude/claude-opus-5-5) <[email protected]> Signed-off-by: ernestrc <[email protected]>
The test runs the rune on PATH as `rune -x <dir>`, which without --datadir installs into ~/.rune. It runs under make test, and so on every commit's pre-commit hook, where it wrote server logs, crash reports and provisioned packages into the developer's own data dir. With this branch's binary on PATH it also moved ~/.rune/zdot to ~/.rune/shellrc, out from under the installed Rune and its running shells. Co-Authored-By: Rune Agent (claude/claude-opus-5-5) <[email protected]> Signed-off-by: ernestrc <[email protected]>
Only $SHELL shell got key binding configs, so zsh, bash or fish configured through terminal.shell started without them, and <esc> never entered modal mode. Co-Authored-By: Rune Agent (claude/claude-opus-5-5) <[email protected]> Signed-off-by: ernestrc <[email protected]>
5efcff0 to
08b83c2
Compare
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Fixes #98. The design and the
inputrcare taken from the issue as written.Modal mode only engaged under zsh. The vte synchronizes with the shell by writing
^A^Gto the ptyand waiting for the bell, but bash's vi-insert keymap self-inserts both bytes, and fish binds
neither, so the handshake never completed and
^A^Gshowed up in the command line.inputrcships next to the bundled zsh dotfiles, andINPUTRCis exported when thelogin shell is bash and the file exists (readline does not fall back to
~/.inputrcwhenINPUTRCnames a missing file). It includes the system and user files first and binds^A/^Gin every keymap under
$if Bash, so runtimeset -o viworks and other readline programs areunaffected. Installed with the other zdot files and added to the Linux bundle.
--init-commandwhen the shell starts with the defaultlogin arguments; they run after
config.fishand survivefish_vi_key_bindings.Tests: hermetic cases in
TestStartCommandforINPUTRC(present / missing) and the fisharguments (defaulted / explicit); e2e cases (
-tags e2e) drive bash and fish through a real pty inmodal mode, alongside the existing zsh case as a control. Verified against bash 5.1.16, fish 4.9.3
and zsh 5.8.1. Before the change the bash e2e case shows the literal
^A^Gin the prompt and thefish case never enters modal mode.