/sensible

Utilities to find and spawn a sensible editor

Primary LanguageGoMIT LicenseMIT

sensible

Utilities to find and spawn a sensible editor.

EDITOR and VISUAL environment variables are used first to find the user's preferred editor. If these are not set, a list of commonly installed editors is used.

Usage

Find a sensible editor

package main

import (
	"fmt"

	"github.com/ernestrc/sensible/editor"
)

func main() {
	e, err := editor.FindEditor()

	if err != nil {
		panic(err)
	}

	fmt.Println(e.GetPath())
}

Edit a file

package main

import (
	"io/ioutil"

	"github.com/ernestrc/sensible/editor"
)

func main() {
	f1, _ := ioutil.TempFile("/tmp", "")
	if err := editor.Edit(f1); err != nil {
		panic(err)
	}
}

go run some of the examples to see more advanced use-cases.

Documentation

http://godoc.org/github.com/ernestrc/sensible/editor