feat: allow choosing editor in configuration file - #955
Open
Metbcy wants to merge 1 commit into
Open
Conversation
Adds an `editor` key to glow.yml so users can pick the editor used by `glow config` and the in-TUI 'e' key without having to override $EDITOR globally. Useful for cases like preferring `micro` for markdown while keeping `vim` as the system default. When set, the value is applied to glow's own process environment before the embedded `charmbracelet/x/editor` package is invoked, so the existing $EDITOR / nano fallback chain remains intact when the key is empty or absent. The override does not leak into the user's shell. Closes charmbracelet#944
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.
Closes #944.
Adds an
editorkey toglow.ymlso users can pick the editor used byglow configand the in-TUIekey without having to override$EDITORglobally. The use case from the issue is wantingmicrofor markdown while keepingvimas the system default.Behavior
editor: "micro"→ glow usesmicro, ignoring$EDITOR.editor: "code --wait"→ multi-token commands work (thex/editorpackage already splits on whitespace).editor: ""or unset → existing$EDITOR→nanofallback chain is untouched.Implementation note
When the key is set, the value is applied to glow's own process environment in
validateOptionsbeforeeditor.Cmdruns. This keeps the diff tiny (no plumbing throughui.Config, no fork of the upstreamcharmbracelet/x/editorpackage) and only mutates glow's own process, so the user's shell$EDITORis not affected.Verified locally
editor: "/bin/echo override"+ a stubEDITOR→ fake editor invoked with the config file path.editor: ""+EDITOR=/bin/echo→$EDITORis used.go build ./...,go vet ./...,go test ./...all pass.