Skip to content

feat(editor): use $EDITOR instead of hardcoded zed#2

Open
ericgoodwin wants to merge 3 commits into
jbachhardie:mainfrom
ericgoodwin:03-31-feat_use_editor_env_var_instead_of_hardcoded_zed_for_editor_shortcut
Open

feat(editor): use $EDITOR instead of hardcoded zed#2
ericgoodwin wants to merge 3 commits into
jbachhardie:mainfrom
ericgoodwin:03-31-feat_use_editor_env_var_instead_of_hardcoded_zed_for_editor_shortcut

Conversation

@ericgoodwin
Copy link
Copy Markdown
Contributor

@ericgoodwin ericgoodwin commented Apr 1, 2026

Overview

Replace the hardcoded zed editor shortcut with a configurable $EDITOR approach, and properly suspend/restore the TUI terminal so editors (especially TUI editors like vim) work correctly.

Main Updates

What changed:

  • The e keybinding now reads $EDITOR instead of spawning zed directly
  • Terminal is suspended before launching the editor and restored after, so TUI editors get a clean terminal
  • The crossterm event reader is aborted before editor launch and restarted after, preventing stdin contention with TUI editors
  • Status bar text updated from "e: zed" to "e: editor"
  • README updated to reflect $EDITOR requirement

Why:

  • The hardcoded zed call only worked for one editor — this makes gitopiary usable for anyone regardless of their editor preference
  • Without terminal suspend/restore, TUI editors (vim, helix, etc.) would render on top of the TUI and break input handling

How to Test Locally

  1. Set $EDITOR to a TUI editor: export EDITOR=vim
  2. Run gitopiary, select a worktree, press e
  3. Verify vim opens cleanly, and after quitting, gitopiary resumes normally
  4. Repeat with a GUI editor (e.g. export EDITOR=code) — it should return immediately and gitopiary stays responsive
  5. Unset $EDITOR (unset EDITOR) and press e — should be a no-op

ericgoodwin and others added 3 commits March 31, 2026 21:14
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Move editor launching from fire-and-forget spawn() in the key handler
to the main event loop via a new OpenEditor event. This lets us properly
suspend TUI state before launching the editor and restore it afterward,
which is necessary for terminal-based editors (vim, neovim) that need a
clean terminal to function correctly.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Extracts the crossterm event reader into a standalone function so it can
be aborted before opening a TUI editor (e.g. vim) and restarted after,
preventing stdin contention.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@ericgoodwin ericgoodwin changed the title Use $EDITOR env var instead of hardcoded zed for editor shortcut feat: use $EDITOR env var instead for editor Apr 1, 2026
@ericgoodwin ericgoodwin changed the title feat: use $EDITOR env var instead for editor feat(editor): use $EDITOR env var instead for editor Apr 1, 2026
@ericgoodwin ericgoodwin changed the title feat(editor): use $EDITOR env var instead for editor feat(editor): use $EDITOR instead of hardcoded zed Apr 1, 2026
@ericgoodwin ericgoodwin closed this Apr 3, 2026
@ericgoodwin ericgoodwin reopened this Apr 3, 2026
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.

1 participant