mirror of
https://github.com/rwinkhart/libmutton.git
synced 2026-08-28 04:46:42 -04:00
32 lines
686 B
Go
32 lines
686 B
Go
//go:build darwin
|
|
|
|
package core
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"os/exec"
|
|
)
|
|
|
|
// copyString copies a string to the clipboard.
|
|
func copyString(continuous bool, copySubject string) {
|
|
cmd := exec.Command("pbcopy")
|
|
writeToStdin(cmd, copySubject)
|
|
err := cmd.Run()
|
|
if err != nil {
|
|
fmt.Println(AnsiError+"Failed to copy to clipboard:", err.Error()+AnsiReset)
|
|
os.Exit(ErrorClipboard)
|
|
}
|
|
|
|
if !continuous {
|
|
LaunchClipClearProcess(copySubject)
|
|
}
|
|
}
|
|
|
|
// getClipCommands returns the commands for pasting and clearing the clipboard contents.
|
|
func getClipCommands() (*exec.Cmd, *exec.Cmd) {
|
|
cmdClear := exec.Command("pbcopy")
|
|
writeToStdin(cmdClear, "")
|
|
return exec.Command("pbpaste"), cmdClear
|
|
}
|