editorname

package
v1.119.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 29, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package editorname resolves the user's configured external editor (VISUAL or EDITOR): a friendly display name used in TUI key-binding hints, and the command that launches the editor over a file.

The environment-reading entry points are thin wrappers over pure functions (FromEnv, CommandFromEnv) that take the raw variable values as parameters, so every code path is testable across platforms and editor configurations without touching the actual process environment.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Command added in v1.119.0

func Command(path string) *exec.Cmd

Command builds the *exec.Cmd that opens path in the configured external editor, reading VISUAL and EDITOR from the process environment.

func CommandFromEnv added in v1.119.0

func CommandFromEnv(visual, editorEnv, path string) *exec.Cmd

CommandFromEnv builds the editor command from raw environment values so tests can exercise every code path without mutating os.Environ. VISUAL wins over EDITOR; the chosen value is split on whitespace (strings.Fields, deliberately no shell evaluation), extra tokens become leading arguments, and path is appended last. When neither variable yields a command, the platform default is launched ("notepad" on Windows, "vi" elsewhere).

func FromEnv

func FromEnv(visual, editorEnv string) string

FromEnv returns a friendly display name for the configured external editor. It reads VISUAL first, then falls back to EDITOR. When neither is set, it returns the platform-specific fallback ("Notepad" on Windows, "Vi" elsewhere) that matches the actual command that will be launched.

FromEnv is pure: it takes the raw environment values as parameters so that tests can exercise every code path without mutating os.Environ.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL