Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fuzzy search to copy current code to clipboard #26

Open
DevopsDood opened this issue Mar 12, 2019 · 3 comments
Open

fuzzy search to copy current code to clipboard #26

DevopsDood opened this issue Mar 12, 2019 · 3 comments
Assignees

Comments

@DevopsDood
Copy link

$ gauth google

copied google OTP to clipboard

@jtmkrueger
Copy link

jtmkrueger commented Apr 24, 2019

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).

@junkblocker
Copy link

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
}

@pcarrier
Copy link
Owner

pcarrier commented Jan 29, 2021

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?

@pcarrier pcarrier self-assigned this Jan 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants