Repository navigation
Description
Summary
Modal (vi) mode in Rune terminals only works with zsh. Under bash (including set -o vi) and fish it never engages: the vte synchronizes with the shell by writing ^A^G to the pty and waiting for the echoed BEL (internal/term/vte/remote.go:154, wait_parser_handler.go:109). Bash's vi-insert keymap self-inserts both bytes (hence the visible ^A^G), and fish binds neither.
Both fixes below were verified empirically through a pty (bash 3.2 emacs/vi, runtime set -o vi, .inputrc editing-mode vi; fish 4.2 default, vi mode, user rebinds in config.fish).
Design decisions
- bash →
INPUTRCinjection. Ship aninputrcnext to the zsh dotfiles in the existing bundledzdot/directory and exportINPUTRC=<zdotdir>/inputrcwhen the resolved login shell is bash. This reuses all existing plumbing (bundle →installZdotDir→--rune-zdotdir→ configzdotdir→fileScheme.zdotDir, including the remote-config path for SSH), so no new flag/option/config key. Guard withos.Stat: readline does not fall back to~/.inputrcwhen$INPUTRCpoints at a missing file, so a stale/customzdotdirmust not silently eat the user's bindings.- Alternative (not chosen): a separate
inputrcconfig key +--rune-inputrcflag +ide.WithInputrc. More explicit but ~6 parallel plumbing touches for no functional gain.
- Alternative (not chosen): a separate
- fish →
-C/--init-command. No file to ship. Runs afterconfig.fish, so it beats user rebinds and survivesfish_vi_key_bindings(which only erases--presetbindings). Applied only whenStartCommanddefaults the args (interactive login-shell contract), matching where--login -iis chosen. Uses legacy\ca/\cgnotation, valid on fish 3.x and 4.x.
Changes
1. New bundled file extra/osx/Rune.app/Contents/Resources/zdot/inputrc
# Rune terminal readline bindings; see internal/workspace/file_scheme.go.
$include /etc/inputrc
$include ~/.inputrc
$if Bash
set bell-style audible
set keymap vi-insert
"\C-a": beginning-of-line
"\C-g": abort
set keymap vi-command
"\C-g": abort
set keymap emacs
"\C-a": beginning-of-line
"\C-g": abort
$endif
- Binding each keymap unconditionally (not
$if mode=vi) is what makes runtimeset -o viwork: keymaps are global and readline restores the active one from the edit mode after parsing. $if Bashkeeps the override away from other readline programs (python, gdb, psql) that inheritINPUTRCfrom the Rune shell.- macOS bundling is automatic (
cp -fRp $(APP_TEMPLATE)).
2. cmd/rune/main.go
zdotFiles: append"inputrc"soinstallZdotDirmirrors it into<datadir>/zdot. ExistingTestInstallZdotDir*tests iteratezdotFilesand cover it.
3. Linux packaging
cmd/rune/Makefilemake-release-linux: addcp .../zdot/inputrc .../rune.app/share/zdot/; update the layout comment at line 364.deploy/rune-linux/Dockerfile(~line 206): samecp.deploy/rune-linux/README.mdlayout block: listinputrcunderzdot/.
4. internal/workspace/file_scheme.go — StartCommand (lines 383-391)
Replace the zsh-only branch with a switch on filepath.Base(cmd.Path) inside the empty-Path block:
argsDefaulted := len(cmd.Args) == 0
if argsDefaulted { cmd.Args = []string{"--login", "-i"} }
switch filepath.Base(cmd.Path) {
case "zsh":
if p.zdotDir != "" { cmd.Env = append(cmd.Env, "ZDOTDIR="+p.zdotDir) }
case "bash":
if p.zdotDir != "" {
inputrc := filepath.Join(p.zdotDir, "inputrc")
if _, err := p.osStat(inputrc); err == nil {
cmd.Env = append(cmd.Env, "INPUTRC="+inputrc)
}
}
case "fish":
if argsDefaulted { cmd.Args = append(cmd.Args, "-C", FishInitCommand) }
}Add:
// FishInitCommand binds ^A/^G in fish so the vte's bell handshake
// (see vte.ptyWriter.triggerBell) works: fish binds neither by default
// and has no beep widget, so ^G prints BEL itself.
const FishInitCommand = `bind \ca beginning-of-line; bind \cg 'printf \a'; ` +
`bind -M insert \ca beginning-of-line; bind -M insert \cg 'printf \a'`Exported so the vte e2e test can reuse it. Use p.osStat (already a field) so tests can stub it. Update the zdotDir field comment to say it also hosts the bash inputrc.
5. Tests
Hermetic — internal/workspace/file_scheme_test.go (same trampoline pattern as the existing zsh subtests, SHELL pointed at a script whose basename is bash/fish):
bash exports INPUTRC when <zdotdir>/inputrc exists— createzdotdirtmp with aninputrc;-c 'echo INPUTRC=$INPUTRC'→INPUTRC=<zdotdir>/inputrc.bash leaves INPUTRC untouched when inputrc is missing— same without the file;t.Setenv("INPUTRC",""); expectunset.fish defaults args to --login -i -C <FishInitCommand>— trampolineprintf '%s\n' "$@";Argsnil; assert stdout lines equal--login,-i,-C,FishInitCommand. (The trampoline only echoes args; it doesn't need to be fish.)fish with explicit Args gets no -C.- Existing "without zsh leaves ZDOTDIR untouched" test keeps passing.
e2e — internal/term/vte (//go:build e2e, skip when the shell isn't installed, like TestZshEdgeCases):
handler_test.go: generalizetestSequenceShellintotestSequenceCommand(t, cfg, timeout, commandAndArgs []string, cases); keeptestSequenceShellas a one-line wrapper.vi_test.goTestBashViModeEdgeCases: reproduces the bug (TDD). Temp rcfile withset -o viandPS1='$ ';os.Setenv("INPUTRC", "<repo>/extra/osx/Rune.app/Contents/Resources/zdot/inputrc")(path relative to the package dir); command[bash --noprofile --rcfile <rc> -i];cfg.Modal = true; a case like"echo blaaa<0Cecho hi"expecting the prompt row$ echo hi▐. Without the inputrc the sequence shows^A^Gand never enters modal mode, so the test fails before the fix.vi_test.goTestFishEdgeCases: command[fish --no-config -i -C "<workspace.FishInitCommand>; function fish_prompt; printf '$ '; end"]; same style case. Risk to check while running it: fish 4 probes DA1/CPR at startup (\x1b[0c,\x1b[6n); if the vte doesn't answer, fish proceeds after its own short timeout, so the first case may need a slightly larger idle wait.
6. Out of scope / notes
ideConfig.zdotDir(internal/ide/config.go:265) is write-only dead plumbing; left alone.- Users who disable the bell (
bind 'set bell-style none'in.bashrc,unsetopt beep) still hit the existing "modal mode cannot be enabled" warning; unchanged.
Verification
go test -race ./internal/workspace/ ./cmd/rune/
go test -race -tags e2e -run 'TestBashViModeEdgeCases|TestFishEdgeCases|TestZshEdgeCases' ./internal/term/vte/
make lint && make test
Manual: launch Rune with SHELL=/bin/bash, run set -o vi, press <esc> → modal mode engages, no ^A^G echo; same with SHELL=$(which fish).
Activity
Fix terminal modal mode for bash and fish via bell bindings
Fix terminal modal mode for bash and fish via bell bindings