From 25ab273419889081363b1dad29e68a9ac160faf0 Mon Sep 17 00:00:00 2001 From: Rasmus Lindroth Date: Tue, 24 Mar 2020 16:43:16 +0100 Subject: [PATCH] Use nvim and default to vi --- README.md | 25 +++++++++++++++++++++++++ util.go | 6 +++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e7128b6..142eac4 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,31 @@ Explanation of the non obvious keys when viewing a toot * `O` = open. Gives you a list of all URLs in the toot. Opens them in your default browser. * `M` = media. Opens the media with `xdg-open`. +### Install instructions +If you don't use the binary that you find under releases +you will need Go. Use a newer one that supports modules. + +```bash +# First clone this repository +git clone https://github.com/RasmusLindroth/tut.git + +# Go to that folder +cd tut + +# Build or install + +# Install (usally /home/user/go/bin) +go install + +#Build (same directory i.e. ./ ) +go build +``` + +If you choose to install and want to be able to just run `tut` +you will have to add `go/bin` to your `$PATH`. + + + ### On my TODO-list: * Support for config files (theme, default image/video viewer) * Multiple accounts diff --git a/util.go b/util.go index c46fbf8..3160b87 100644 --- a/util.go +++ b/util.go @@ -62,6 +62,10 @@ func cleanTootHTML(content string) (string, []URL) { } func openEditor(app *tview.Application, content string) (string, error) { + editor, exists := os.LookupEnv("EDITOR") + if !exists || editor == "" { + editor = "vi" + } f, err := ioutil.TempFile("", "tut") if err != nil { return "", err @@ -72,7 +76,7 @@ func openEditor(app *tview.Application, content string) (string, error) { return "", err } } - cmd := exec.Command("nvim", f.Name()) + cmd := exec.Command(editor, f.Name()) cmd.Stdin = os.Stdin cmd.Stdout = os.Stdout var text []byte