You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've put together a little ZSH function to handle it, if you want to use it!
# shows the auth thing and puts the auth you want in the paste buffer
# pass the auth you want as an argument in the paste buffer
# dependency: https://github.com/pcarrier/gauth
# EX: mfa AWS
function mfa() {
gauth
gauth | grep $1 | awk '{$1=$2=$4=""; print $0}' | sed 's/ //g' | pbcopy
}
I just have it in my .zshrc. If you don't have pbcopy, you'll have to sub something else in (like xclip).
Nice @jtmkrueger ! I made some slight modifications to yours to make it 1) ignore case in query 2) be able to handle mfa entry names with spaces in them and 3) added the xclip bit.
mfa () {
local paster
if [ -z "$(command -v gauth)" ]
then
echo "gauth is not available" >&2
return 1
fi
paster=cat
case "$(uname -s)" in
([Dd]arwin*) paster="pbcopy" ;;
([Ll]inux*) paster="xclip -i" ;;
esac
gauth
gauth | grep -i "$1" | awk '{print $(NF-1)}' | $paster
}
Oh. Yes. Might not deal with the clipboard part because that's desktop-specific (unless there's a good go lib that does more or less everything for us without native bindings and co making compilation hard?), but could make gauth much nicer for this (eg gauth -current goog finds anything named *goog*).
What would you expect to happen if we find multiple matches or no matches?
$
gauth google
copied google OTP to clipboard
The text was updated successfully, but these errors were encountered: