diff options
author | Ensa <psychoticfervor@tuta.io> | 2019-12-20 00:14:09 -0800 |
---|---|---|
committer | Ensa <psychoticfervor@tuta.io> | 2019-12-20 00:14:09 -0800 |
commit | 4684d80b6271dd775cd23dabf2b91d6ce56fa33a (patch) | |
tree | ddb6c6219e213132b8500e016b1ce238aa71029d /bin/pw | |
parent | f733ca7c8041866df27752c8e0c2610e0ecef6a7 (diff) | |
download | cfg-4684d80b6271dd775cd23dabf2b91d6ce56fa33a.tar.gz |
first significant commit
see README.md for information
Diffstat (limited to 'bin/pw')
-rwxr-xr-x | bin/pw | 14 |
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&¬ify-send "Password Generated" "$1-character password generated. It will clear in 10 seconds." + sleep 10 + printf "\0"|xclip -sel clip -i&¬ify-send "Clipboard Cleared" "Generated password cleared from clipboard." +else + printf '%s\n' "$PW" +fi |