From 76604463dc2925c027d1d5b0cfbba9524602b50a Mon Sep 17 00:00:00 2001 From: Leif Wesche Date: Sun, 21 Mar 2021 21:35:42 -0700 Subject: [PATCH] Fixed issue with random chars from vim on mac, helpful failure for -c without a file, added CTRL+O to README --- README.md | 1 + commands.go | 11 ++++++++++- wuzz.go | 3 +++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a7f853f..d749f7b 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,7 @@ Keybinding | Description Ctrl+C | Quit Ctrl+K, Shift+Tab | Previous view Ctlr+J, Tab | Next view +Ctrl+O | Open view in text editor Ctlr+T | Toggle context specific search Alt+H | Toggle history Down | Move down one view line diff --git a/commands.go b/commands.go index f312896..ea3dca9 100644 --- a/commands.go +++ b/commands.go @@ -5,6 +5,7 @@ import ( "io/ioutil" "os" "os/exec" + "runtime" "strings" "unicode" @@ -12,6 +13,8 @@ import ( "github.com/nsf/termbox-go" ) +const MAC_OS = "darwin" + type CommandFunc func(*gocui.Gui, *gocui.View) error var COMMANDS map[string]func(string, *App) CommandFunc = map[string]func(string, *App) CommandFunc{ @@ -236,7 +239,13 @@ func openEditor(g *gocui.Gui, v *gocui.View, editor string) error { return nil } - cmd := exec.Command(editor, file.Name()) + var cmd *exec.Cmd + // Some .vimrc files might not play nice. To play it safe, don't use them. + if editor == "vim" && runtime.GOOS == MAC_OS { + cmd = exec.Command(editor, "-u", "NONE", file.Name()) + } else { + cmd = exec.Command(editor, file.Name()) + } cmd.Stdout = os.Stdout cmd.Stdin = os.Stdin cmd.Stderr = os.Stderr diff --git a/wuzz.go b/wuzz.go index 258bcb7..60e9b13 100644 --- a/wuzz.go +++ b/wuzz.go @@ -1845,6 +1845,9 @@ func main() { fmt.Printf("wuzz %v\n", VERSION) return case "-c", "--config": + if i+1 >= len(os.Args) { + log.Fatal("Expected file after -c") + } configPath = os.Args[i+1] args = append(os.Args[:i], os.Args[i+2:]...) if _, err := os.Stat(configPath); os.IsNotExist(err) {