NameSizeMode
..
.local/bin/getpass 601 bytes ?rwxr-xr-x
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/sh
# Copy passwords from pass(1) to the clipboard, and then clear the clipboard
# after a while
#
# Usage: getpass [KEY]
# Dependencies: pass(1), xclip(1), notify-send(1)
#
# Pablo (C) 2023
# Free use of this software is granted under the terms of the GPL-3.0 License

set -e
delay=15

clear_clipboard ()
{
  sleep "$delay"
  echo | xclip -selection clipboard
  notify-send "Clipboard cleared"
}

if [ $# -gt 0 ]; then
  pass "$1" | xclip -selection clipboard
  notify-send "Copied the '$1' password to clipboard. Clipboard will be cleared in $delay seconds"
  clear_clipboard &
else
  pass
fi