From eee1e8e3334bbdde932ded44e8e185185da695fe Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Wed, 18 Jul 2018 19:51:34 +0800 Subject: zsh: Add function randpass() to generate random string --- _zsh/40-functions.zsh | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to '_zsh/40-functions.zsh') diff --git a/_zsh/40-functions.zsh b/_zsh/40-functions.zsh index 99f17de..a9d30ed 100644 --- a/_zsh/40-functions.zsh +++ b/_zsh/40-functions.zsh @@ -133,4 +133,12 @@ zapply() { printf '%s\0' "$@[s+1,-1]" | xargs -0 -r -n1 ${(kv)=xopt} "$@[1,s-1]" } + +## Generate random password/string +randpass() { + local len=${1:-16} + tr -dc '[:alnum:]'