From d2b7b4c0f0b4554ecb3793dd44a6384b3bf22a41 Mon Sep 17 00:00:00 2001 From: Andrea Rogers Date: Tue, 12 Nov 2024 10:16:23 -0600 Subject: [PATCH] aliases: Add password generator "aliases" Implemented with Bash functions, saved in ".aliases" dir, cause it all gets sourced the same (and I am lazy) --- .aliases/passwords.bash | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .aliases/passwords.bash diff --git a/.aliases/passwords.bash b/.aliases/passwords.bash new file mode 100644 index 0000000..cf9c106 --- /dev/null +++ b/.aliases/passwords.bash @@ -0,0 +1,14 @@ +: ' + * A file with some password-creation/management "aliases" + ' + +_tmkpasswd() { + [ -n "$1" ] && local passlen=$1 || local passlen=20 + echo $(cat /dev/"$2"random | strings | head -c 512 | grep -oE '[a-zA-Z0-9#@$%!]')\ + | sed 's/\s//g' | head -c $passlen +} + +tmkpasswd() { + [ $(command -v wl-copy) ] && _tmkpasswd $@ | wl-copy || \ + ( _tmkpasswd $@ && echo ) +}