| 1145 | } |
| 1146 | |
| 1147 | func copyToClipboard(text string) error { |
| 1148 | candidates := [][]string{ |
| 1149 | {"pbcopy"}, |
| 1150 | {"wl-copy"}, |
| 1151 | {"xclip", "-selection", "clipboard"}, |
| 1152 | {"xsel", "--clipboard", "--input"}, |
| 1153 | {"clip"}, |
| 1154 | } |
| 1155 | |
| 1156 | for _, candidate := range candidates { |
| 1157 | bin := candidate[0] |
| 1158 | if _, err := exec.LookPath(bin); err != nil { |
| 1159 | continue |
| 1160 | } |
| 1161 | |
| 1162 | cmd := exec.Command(bin, candidate[1:]...) |
| 1163 | cmd.Stdin = strings.NewReader(text) |
| 1164 | if err := cmd.Run(); err == nil { |
| 1165 | return nil |
| 1166 | } |
| 1167 | } |
| 1168 | |
| 1169 | return errors.New("no clipboard command available (tried pbcopy, wl-copy, xclip, xsel, clip)") |
| 1170 | } |
| 1171 | |
| 1172 | func runDeploy() error { |
| 1173 | home, err := os.UserHomeDir() |