about summary refs log tree commit diff stats
path: root/bin/pw
diff options
context:
space:
mode:
authorEnsa <psychoticfervor@tuta.io>2019-12-20 00:14:09 -0800
committerEnsa <psychoticfervor@tuta.io>2019-12-20 00:14:09 -0800
commit4684d80b6271dd775cd23dabf2b91d6ce56fa33a (patch)
treeddb6c6219e213132b8500e016b1ce238aa71029d /bin/pw
parentf733ca7c8041866df27752c8e0c2610e0ecef6a7 (diff)
downloadcfg-4684d80b6271dd775cd23dabf2b91d6ce56fa33a.tar.gz
first significant commit
see README.md for information
Diffstat (limited to 'bin/pw')
-rwxr-xr-xbin/pw14
1 files changed, 14 insertions, 0 deletions
diff --git a/bin/pw b/bin/pw
new file mode 100755
index 0000000..140f1dc
--- /dev/null
+++ b/bin/pw
@@ -0,0 +1,14 @@
+#!/bin/sh
+# generates a password of length $1, sends it to stdout if $2 isn't clip.
+# if it is clip, sends it to the X clipboard and clears it after 10 seconds.
+if [ "$1" = "-h" ]; then
+	printf 'usage: %s [-h]|LENGTH [clip]\n' "$(basename $0)">/dev/stderr&&return 1
+fi
+PW=$(tr -cd "[:alnum:][:punct:]"</dev/urandom|fold -w $1|head -1)
+if [ "$2" = "clip" ]; then
+	printf '%s' "$PW"|xclip -sel clip -i&&notify-send "Password Generated" "$1-character password generated. It will clear in 10 seconds."
+	sleep 10
+	printf "\0"|xclip -sel clip -i&&notify-send "Clipboard Cleared" "Generated password cleared from clipboard."
+else
+	printf '%s\n' "$PW"
+fi