From aecc7afb4c41432263608a191c2fd9890015feee Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Thu, 22 Jan 2026 01:10:15 -0800 Subject: [PATCH] [NixOS] Add passgen --- dotfiles/lib/functions/passgen | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 dotfiles/lib/functions/passgen diff --git a/dotfiles/lib/functions/passgen b/dotfiles/lib/functions/passgen new file mode 100644 index 00000000..d706c748 --- /dev/null +++ b/dotfiles/lib/functions/passgen @@ -0,0 +1,18 @@ +#!/usr/bin/env sh + +function passgen { + if [ -z "$1" ]; then + echo "Usage: passgen " >&2 + return 1 + fi + + local base_pass upper symbol password + base_pass="$(xkcdpass -n 3 | tr -d ' ')" + upper="$(echo {A..Z} | tr ' ' '\n' | shuf -n1)" + symbol="$(echo '!@#$%^&*' | fold -w1 | shuf -n1)" + password="${base_pass}${upper}${symbol}" + + echo "$password" | pass insert -e "$1" +} + +passgen