Skip to content

Fix terminal modal mode for bash and fish via bell bindings - #114

Merged
ernestrc merged 6 commits into
unstablebuild:mainfrom
ejb711:fix-vi-mode-bash-fish
Oct 1, 2026
Merged

ernestrc merged 6 commits into
unstablebuild:mainfrom
ejb711:fix-vi-mode-bash-fish

Conversation

@ejb711

@ejb711 ejb711 commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Fixes #98. The design and the inputrc are taken from the issue as written.

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.

  • bash: an inputrc ships next to the bundled zsh dotfiles, and INPUTRC is exported when the
    login shell is bash and the file exists (readline does not fall back to ~/.inputrc when
    INPUTRC names a missing file). It includes the system and user files first and binds ^A/^G
    in every keymap under $if Bash, so runtime set -o vi works and other readline programs are
    unaffected. Installed with the other zdot files and added to the Linux bundle.
  • fish: the bindings are passed with --init-command when the shell starts with the default
    login arguments; they run after config.fish and survive fish_vi_key_bindings.

Tests: hermetic cases in TestStartCommand for INPUTRC (present / missing) and the fish
arguments (defaulted / explicit); e2e cases (-tags e2e) drive bash and fish through a real pty in
modal 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^G in the prompt and the
fish case never enters modal mode.

@zhengqunkoo

Copy link
Copy Markdown
Contributor

Can confirm this fix works for bash

Comment thread internal/workspace/file_scheme.go Outdated
if p.zdotDir != "" {
inputrc := filepath.Join(p.zdotDir, "inputrc")
if _, err := p.osStat(inputrc); err == nil {
cmd.Env = append(cmd.Env, "INPUTRC="+inputrc)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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:

  1. nested bash receives INPUTRC;
  2. nested zsh receives ZDOTDIR;

Comment thread internal/workspace/file_scheme.go Outdated
// 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")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

@zhengqunkoo

zhengqunkoo commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

New observed issue: adding set -o vi to ~/.bashrc, the fix no longer works doesn't work in a new terminal (pressing Escape prints ^A^G again instead of going to Rune Normal mode)

  • It includes the system and user files first and binds ^A/^G
    in every keymap under $if Bash, so runtime set -o vi works and other readline programs are

and also, runtime set -o vi doesn't work - if set editing-mode vi is added to ~/.inputrc, there is the same issue of pressing Escape prints ^A^G again instead of going to Rune Normal mode

ejb711 and others added 6 commits October 1, 2026 15:29
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]>
@ernestrc
ernestrc force-pushed the fix-vi-mode-bash-fish branch from 5efcff0 to 08b83c2 Compare October 1, 2026 13:48
@ernestrc
ernestrc enabled auto-merge (rebase) October 1, 2026 13:49
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 52.13675% with 56 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cmd/rune/main.go 43.33% 17 Missing ⚠️
internal/workspace/file_scheme.go 66.66% 17 Missing ⚠️
internal/term/vte/handler.go 0.00% 6 Missing ⚠️
internal/term/vte/vi.go 0.00% 4 Missing ⚠️
cmd/rune/headless.go 0.00% 3 Missing ⚠️
internal/term/vte/remote.go 0.00% 3 Missing ⚠️
cmd/rune/network.go 66.66% 2 Missing ⚠️
internal/ide/option.go 0.00% 2 Missing ⚠️
cmd/rune/bootstrap_handler.go 66.66% 1 Missing ⚠️
cmd/rune/provision.go 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@ernestrc
ernestrc merged commit 587cdfd into unstablebuild:main Oct 1, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix terminal modal (vi) mode for bash and fish via bell bindings

4 participants