aboutsummaryrefslogtreecommitdiffstats
path: root/_zsh
diff options
context:
space:
mode:
authorAaron LI <aly@aaronly.me>2018-07-18 19:51:34 +0800
committerAaron LI <aly@aaronly.me>2018-07-18 19:52:44 +0800
commiteee1e8e3334bbdde932ded44e8e185185da695fe (patch)
treeb47ae8f7888ed5833701fc5233a47f4a4efcd182 /_zsh
parente53e4f9eb3056a80470846afbc7578a57cf3ab98 (diff)
downloaddotfiles-eee1e8e3334bbdde932ded44e8e185185da695fe.tar.bz2
zsh: Add function randpass() to generate random string
Diffstat (limited to '_zsh')
-rw-r--r--_zsh/40-functions.zsh8
1 files changed, 8 insertions, 0 deletions
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:]' </dev/urandom | head -c ${len} | xargs
+}
+
+
# vim: set ts=8 sw=4 tw=0 fenc=utf-8 ft=zsh: #