From fdb8b1a194073a6950054468b6d4d03869418c6c Mon Sep 17 00:00:00 2001 From: James Blair Date: Wed, 27 Mar 2024 03:44:40 +1300 Subject: [PATCH] Auto generate new random pw if not supplied. --- .bashrc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.bashrc b/.bashrc index 5ba591c..d7f94c2 100644 --- a/.bashrc +++ b/.bashrc @@ -54,21 +54,24 @@ function bwgu () { local test=$(export BW_SESSION=~/.bw_session) && bw get usern function bwai () { # Verify enough parameters are supplied - if [ "$#" -lt "3" ]; then + if [ "$#" -lt "2" ]; then echo 'Ensure all required parameters are supplied:' echo ' $1 = Name for item' echo ' $2 = Username for item' - echo ' $3 = Secret for item' + echo ' $3 = Secret for item (optional)' echo ' $4 = Url for item (optional)' return 2 fi + # Use a generated password if none supplied + local pass="${3:-$(tr -dc A-Za-z0-9