mirror of
https://github.com/eeeXun/GTT.git
synced 2025-05-15 23:30:27 -07:00
34 lines
563 B
Go
34 lines
563 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os/exec"
|
|
"runtime"
|
|
)
|
|
|
|
func IndexOf(candidate string, arr []string) int {
|
|
for index, element := range arr {
|
|
if element == candidate {
|
|
return index
|
|
}
|
|
}
|
|
return -1
|
|
}
|
|
|
|
func SetTermTitle(title string) {
|
|
print("\033]0;", title, "\007")
|
|
}
|
|
|
|
func CopyToClipboard(text string) {
|
|
switch runtime.GOOS {
|
|
case "linux":
|
|
exec.Command("sh", "-c",
|
|
fmt.Sprintf("echo -n '%s' | xclip -selection clipboard", text)).
|
|
Start()
|
|
case "darwin":
|
|
exec.Command("sh", "-c",
|
|
fmt.Sprintf("echo -n '%s' | pbcopy", text)).
|
|
Start()
|
|
}
|
|
}
|