init --copy: put the recovery phrase on the clipboard
Opt-in, as one line of words. Uses wl-copy, xclip, xsel, pbcopy or clip.exe, and falls back to asking the terminal (OSC 52), which works over SSH. The output says how it was copied and to clear the clipboard afterwards. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AeFqV96dVeBX94inzcgZKw
This commit is contained in:
@@ -21,6 +21,7 @@ import (
|
||||
func cmdInit(args []string) error {
|
||||
fs := flag.NewFlagSet("init", flag.ExitOnError)
|
||||
data := dataFlag(fs)
|
||||
copyWords := fs.Bool("copy", false, "also copy the 12 words to the clipboard, as one line for pasting")
|
||||
fs.Parse(args)
|
||||
|
||||
if _, err := os.Stat(filepath.Join(*data, "device.key")); err == nil {
|
||||
@@ -33,6 +34,13 @@ func cmdInit(args []string) error {
|
||||
}
|
||||
words := strings.Fields(phrase)
|
||||
showPhrase(words)
|
||||
if *copyWords {
|
||||
var tty *os.File
|
||||
if term.IsTerminal(int(os.Stdout.Fd())) {
|
||||
tty = os.Stdout // only a real terminal can act on the OSC 52 fallback
|
||||
}
|
||||
copyPhrase(words, tty)
|
||||
}
|
||||
|
||||
// Only ask for confirmation when a person is at the keyboard.
|
||||
if term.IsTerminal(int(os.Stdin.Fd())) {
|
||||
|
||||
Reference in New Issue
Block a user