Skip to content

Commit 43b1c14

Browse files
author
Anand
committed
Clipboard copy flag with password copy support
1 parent 3b73e22 commit 43b1c14

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

utils.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"encoding/json"
88
"errors"
99
"fmt"
10+
"github.com/atotto/clipboard"
1011
"github.com/kirsle/configdir"
1112
"golang.org/x/crypto/ssh/terminal"
1213
"io/fs"
@@ -20,6 +21,7 @@ const DELIMSIZE int = 69
2021
// Over-ride settings via cmd line
2122
type SettingsOverride struct {
2223
ShowPasswords bool
24+
CopyPassword bool
2325
}
2426

2527
// Settings structure for local config
@@ -389,6 +391,16 @@ func setShowPasswords() error {
389391
return nil
390392
}
391393

394+
// Copy the password to clipboard - only for single listings or single search results
395+
func setCopyPasswordToClipboard() error {
396+
settingsRider.CopyPassword = true
397+
return nil
398+
}
399+
400+
func copyPasswordToClipboard(passwd string) {
401+
clipboard.WriteAll(passwd)
402+
}
403+
392404
// Generate a random file name
393405
func randomFileName(folder string, suffix string) string {
394406

0 commit comments

Comments
 (0)