Easy password generator using bash on Mac OS X

Prerequisites:

  • homebrew
  • .bashrc/.bash_profile 
  • OS X 10.8+

Install

$ brew install pwgen

Configure

$ vim ~/.bash_profile

# Paste the following function
genpasswd() {
    pwgen -Bs $1 1 |pbcopy |pbpaste; echo "Has been copied to clipboard"
}

Usage

$ genpasswd 25
VyxjFrRnoFkAP7bpAzRKB2t4k
Has been copied to clipboard