commit 5da5729018da121fbf30dd5b4ad1372ed26b623c
parent 9ed42ab35a8b48e2b86a9f5bd67505b933841a65
Author: Sean Enck <sean@ttypty.com>
Date: Tue, 12 Jul 2022 18:58:30 -0400
get executable in most cases
Diffstat:
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/cmd/lb/main.go b/cmd/lb/main.go
@@ -224,7 +224,11 @@ func main() {
}
internal.CopyToClipboard("")
default:
- tryCommand := fmt.Sprintf("lb-%s", command)
+ exe, err := os.Executable()
+ if err != nil {
+ internal.Die("unable to get exe", err)
+ }
+ tryCommand := fmt.Sprintf(filepath.Join(exe, "lb-%s"), command)
c := exec.Command(tryCommand, args[2:]...)
c.Stdout = os.Stdout
c.Stderr = os.Stderr
diff --git a/internal/clip.go b/internal/clip.go
@@ -4,6 +4,7 @@ import (
"fmt"
"os"
"os/exec"
+ "path/filepath"
"strings"
)
@@ -70,7 +71,11 @@ func CopyToClipboard(value string) {
pipeTo(cp[0], value, true, args...)
if value != "" {
fmt.Printf("clipboard will clear in %d seconds\n", MaxClipTime)
- pipeTo("lb", value, false, "clear")
+ exe, err := os.Executable()
+ if err != nil {
+ Die("unable to get executable", err)
+ }
+ pipeTo(filepath.Join(filepath.Dir(exe), "lb"), value, false, "clear")
}
}