Clear clipboard when copy process is closed

This commit is contained in:
2025-11-10 00:13:49 -05:00
parent 41b4c4b6ca
commit c1c9565511
3 changed files with 15 additions and 4 deletions
+12 -1
View File
@@ -2,6 +2,9 @@ package cli
import (
"fmt"
"os"
"os/signal"
"syscall"
"github.com/rwinkhart/go-boilerplate/back"
"github.com/rwinkhart/go-boilerplate/front"
@@ -36,6 +39,15 @@ func CopyMenu(targetLocation string) {
}
}
// set up signal handling for ctrl+c to clear clipboard
sigChan := make(chan os.Signal, 1)
signal.Notify(sigChan, os.Interrupt, syscall.SIGTERM)
go func() {
<-sigChan
clip.ClipClearProcess("")
os.Exit(0)
}()
// copy selected field to clipboard
for {
choice := front.InputMenuGen("Field to copy:", fields)
@@ -78,5 +90,4 @@ func CopyMenu(targetLocation string) {
}
}
}
// TODO clear clipboard on exit!
}