Skip to content

Instantly share code, notes, and snippets.

@rickythefox
Created December 5, 2025 08:33
Show Gist options
  • Select an option

  • Save rickythefox/df5122a259ae6cb5e4157bc46854ead6 to your computer and use it in GitHub Desktop.

Select an option

Save rickythefox/df5122a259ae6cb5e4157bc46854ead6 to your computer and use it in GitHub Desktop.
pwgen - readable, pronounceable, memorable password generator
#!/bin/bash
# Consonants and vowels for pronounceable passwords
conso=(b c d f g h j k l m n p r s t v w x y z)
vowel=(a e i o u)
spchars=('!' '@' '#' '$' '%' '^' '&' '*' '-' '+' '?' '=' '~')
# Generate a single password
generate_password() {
local len=10
local length=$((len - 2)) # Room for 2-digit number
local max=$((length / 2))
local password=""
# Build consonant-vowel pattern
for ((i = 0; i < max; i++)); do
password+="${conso[RANDOM % ${#conso[@]}]}"
password+="${vowel[RANDOM % ${#vowel[@]}]}"
done
# Replace last char with special character
password="${password%?}${spchars[RANDOM % ${#spchars[@]}]}"
# Add 2-digit number
password+="$((RANDOM % 90 + 10))"
# Capitalize first letter
echo "$(echo "${password:0:1}" | tr '[:lower:]' '[:upper:]')${password:1}"
}
# Generate 10 passwords and pipe to fzf
passwords=""
for i in {1..10}; do
passwords+="$(generate_password)"$'\n'
done
# Show in fzf, copy selection to clipboard
selected=$(echo -n "$passwords" | fzf --height=15 --prompt="Select password: ")
if [[ -n "$selected" ]]; then
echo -n "$selected" | pbcopy
echo "Copied to clipboard: $selected"
fi
@rickythefox
Copy link
Author

Algo from https://www.warpconduit.net/password-generator/ .

Use on macOS to generate 10 passwords, present them using fzf and copy the selected one to clipboard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment