diff options
author | Dennis Eriksen <d@ennis.no> | 2018-05-10 21:08:18 +0200 |
---|---|---|
committer | Dennis Eriksen <d@ennis.no> | 2018-05-10 21:08:18 +0200 |
commit | d42e669fed89978b1a966cd80bfdaa67cba0db73 (patch) | |
tree | f91b9d796c99adf3345843fd976cf9e4a9e82111 | |
download | makepass-d42e669fed89978b1a966cd80bfdaa67cba0db73.tar.gz |
moving scripts out, and updating for stow
-rwxr-xr-x | bin/bin/makepass.sh | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/bin/bin/makepass.sh b/bin/bin/makepass.sh new file mode 100755 index 0000000..cd29da8 --- /dev/null +++ b/bin/bin/makepass.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env zsh +# Copyright (c) 2018 Dennis Eriksen • d@ennis.no + +# makepass-function +function makepass { + local l=$1 + # if $l is not a number, then exit + [[ ! $l = <-> ]] && [[ ! "$l" == "" ]] && echo "not a number" && return 1 + # if $1 is actually empty, set $l to random value for each output + for i in {1..10}; do + [ "$1" = "" ] && l=$(shuf -i 8-44 -n 1) + < /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-$l};echo; + done; + for i in {1..5}; do + [ "$1" = "" ] && l=$(shuf -i 16-64 -n 1) + < /dev/urandom tr -dc '!"#$%&/()=?+-_,.;:<>[]{}|\@*^A-Z-a-z-0-9' | head -c${1:-$l};echo; + done; +} + +makepass "${@:-}" + +# vim:syntax=sh filetype=sh |