Skip to content

Instantly share code, notes, and snippets.

@wlkns
Created May 3, 2018 08:54
Show Gist options
  • Select an option

  • Save wlkns/bb3afc5c2c2db6e51df859e55b24f403 to your computer and use it in GitHub Desktop.

Select an option

Save wlkns/bb3afc5c2c2db6e51df859e55b24f403 to your computer and use it in GitHub Desktop.
Random password command line with password copied to clipboard (Usage: random_password <length default:12>) - Save to /usr/local/bin/random_password and don't forget to chmod +x the resulting file.
#!/bin/sh
LENGTH=${1:-12}
RANDOM_STRING=`openssl rand -base64 ${LENGTH}`
`echo "${RANDOM_STRING}" | tr -d '\n' | pbcopy`
echo "\033[1;32mRandom Password: \033[0m"
echo ""
echo " ${RANDOM_STRING}"
echo ""
echo "\033[1;37mPassword copied to clipboard.\033[0m"
@wlkns

wlkns commented May 3, 2018

Copy link
Copy Markdown
Author

image 2018-05-03 at 9 56 15 am

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment