mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-11 08:20:09 +00:00
fix(genpass): in genpass-xkcd
, add warnings and make it compatible with macOS
Closes #9515 Closes #9516
This commit is contained in:
commit
f2a4b2b17b
1 changed files with 13 additions and 2 deletions
|
@ -73,8 +73,19 @@ genpass-monkey() {
|
|||
|
||||
genpass-xkcd() {
|
||||
# Generates a 128-bit XKCD-style passphrase
|
||||
# EG, 9-mien-flood-Patti-buxom-dozes-ickier-pay-ailed-Foster
|
||||
# e.g, 9-mien-flood-Patti-buxom-dozes-ickier-pay-ailed-Foster
|
||||
# Can take a numerical argument for generating extra passwords
|
||||
|
||||
if (( ! $+commands[shuf] )); then
|
||||
echo >&2 "$0: \`shuf\` command not found. Install coreutils (\`brew install coreutils\` on macOS)."
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [[ ! -e /usr/share/dict/words ]]; then
|
||||
echo >&2 "$0: no wordlist found in \`/usr/share/dict/words\`. Install one first."
|
||||
return 1
|
||||
fi
|
||||
|
||||
local -i i num
|
||||
|
||||
[[ $1 =~ '^[0-9]+$' ]] && num=$1 || num=1
|
||||
|
@ -90,6 +101,6 @@ genpass-xkcd() {
|
|||
|
||||
for i in {1..$num}; do
|
||||
printf "$n-"
|
||||
printf "$dict" | shuf -n "$n" | paste -sd '-'
|
||||
printf "$dict" | shuf -n "$n" | paste -sd '-' -
|
||||
done
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue