From 573df524fed1c493ce7d8ea893f06ab90f2ca18a Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Mon, 20 May 2024 17:06:44 +0900 Subject: Use winpty to launch fzf in Git bash (mintty) Close #3806 Known limitation: * --height cannot be used --- src/proxy_unix.go | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/proxy_unix.go (limited to 'src/proxy_unix.go') diff --git a/src/proxy_unix.go b/src/proxy_unix.go new file mode 100644 index 00000000..189d0e56 --- /dev/null +++ b/src/proxy_unix.go @@ -0,0 +1,38 @@ +//go:build !windows + +package fzf + +import ( + "io" + "os" + + "golang.org/x/sys/unix" +) + +func sh() (string, error) { + return "sh", nil +} + +func mkfifo(path string, mode uint32) (string, error) { + return path, unix.Mkfifo(path, mode) +} + +func withOutputPipe(output string, task func(io.ReadCloser)) error { + outputFile, err := os.OpenFile(output, os.O_RDONLY, 0) + if err != nil { + return err + } + task(outputFile) + outputFile.Close() + return nil +} + +func withInputPipe(input string, task func(io.WriteCloser)) error { + inputFile, err := os.OpenFile(input, os.O_WRONLY, 0) + if err != nil { + return err + } + task(inputFile) + inputFile.Close() + return nil +} -- cgit v1.2.3