Skip to content

Instantly share code, notes, and snippets.

@Ghostbird
Created October 4, 2021 17:15
Show Gist options
  • Save Ghostbird/2d9709b3ea782cf0620d8fdbfe55fb5b to your computer and use it in GitHub Desktop.
Save Ghostbird/2d9709b3ea782cf0620d8fdbfe55fb5b to your computer and use it in GitHub Desktop.
Generate a random password, show it, and add it to the CTLR+V clipboard with this bash one-liner
#!/bin/bash
dd if=/dev/random bs=1 count=${1:-16} 2> /dev/null | base64 | tee >(xclip -selection clip-board);
@Ghostbird
Copy link
Author

I recommend adding this to bash aliases:

genpass() {
     dd if=/dev/random bs=1 count=${1:-16} 2> /dev/null | base64 | tee >(xclip -selection clip-board);
     echo "Password copied to clipboard"
}
Then you can run `genpass` in any bash shell to quickly get a new password.

@Ghostbird
Copy link
Author

Note: If you prefer the GNU/Linux clipboard on middle mouse click, you can remove the -selection clip-board part.

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