Skip to content

Instantly share code, notes, and snippets.

@WallaceTan
Last active April 15, 2021 02:17
Show Gist options
  • Save WallaceTan/859d17b5f5631ca411c1c4d283ea07c4 to your computer and use it in GitHub Desktop.
Save WallaceTan/859d17b5f5631ca411c1c4d283ea07c4 to your computer and use it in GitHub Desktop.
Command line OTP generator and copy generated OTP to MacOS clipboard
# File Path: ~/bin/otp-{APP}-{USERNAME}.sh
#!/bin/bash
# Generate OTP with oathtool and SECRET-KEY from QR-code.
# Pipe to tee
# Strip the ending NEW-LINE ('\n')
# Pipe to MacOS clipboard
echo -e "$(/usr/local/bin/oathtool --totp -b [SECRET-KEY])" | tee >(tr -d '\n' | pbcopy)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment