From 621da400813e209e1c8ecaed8adc1be8a7062fc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?ryan4yin=20=7C=20=E4=BA=8C=E8=8A=B1?= Date: Mon, 21 Sep 2026 17:14:48 +0800 Subject: [PATCH] Merge pull request #293 from ryan4yin/feat/genpass-nu-command feat(shells): add genpass nu command to generate random passwords --- home/base/core/shells/config.nu | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/home/base/core/shells/config.nu b/home/base/core/shells/config.nu index fd6e7cf2..76c34bc2 100644 --- a/home/base/core/shells/config.nu +++ b/home/base/core/shells/config.nu @@ -88,6 +88,12 @@ def dus [path: string = ""] { } } +# Generate a secure random base64 password of `length` characters (default 12). +def genpass [length: int = 12] { + let bytes = (($length * 3 + 2) / 4 | math ceil) + 3 + ^openssl rand -base64 $bytes | str trim | str substring 0..<$length +} + # --------------------------- # Commandline Editor Settings # ---------------------------