ravenac95 / sudolikeaboss

Get 1password access from iterm2
http://sudolikeaboss.com
MIT License
1.51k stars 50 forks source link

Terminal parsing #11

Open lrozema opened 9 years ago

lrozema commented 9 years ago

Is it possible to parse a piece of the terminal (last line for instance) to determine which account to load? And is it possible to chat the password directly from 1pw into the terminal?

For instance I sometimes SSH into a remote server and want to do a git pull one of my private Github repos. I would like to:

me@myserver:~/folder$ git pull Username for 'https://github.com':

And then hit cmd-\ and then have it show my Github web entry. Then when I choose it that it first enters the username and then the password, preferably depending on what the terminal asks.

Maybe in the beginning this could simply be depending on a few chat script like fields inside the different accounts. For instance by setting 'match_login' as 'git pull', 'match_user' as' Username for 'https://github.com':', etc.. Then it could chat with the terminal directly after I hit cmd-\ and choose the account that I want to use?

ravenac95 commented 9 years ago

@lrozema So sorry I didn't respond sooner! That's something I've wanted to experiment with but haven't had time to as of late. I will definitely see if we can do something here.

thorhs commented 7 years ago

This could probably be handled by allowing a username to be specified on the command line when starting the co-process. iTerm triggers could then be used instead of a keypress to start the coprocess. The coprocess could then send the DEFAULT_HOSTNAME string, but with the username included. The triggers can pass in data that is gathered from a regular expression.

lrosenstein commented 7 years ago

That's exactly what I do and it works well. The change I made to make this possible is here: https://github.com/lrosenstein/sudolikeaboss/commit/fb36f082e88e5f6910940be51dce0d6c15ee5d33

thorhs commented 7 years ago

Not bad. What I've wanted to do is to have the option of specifying a user and host, if a user is specified, use: sudolikeaboss://@local and if user and host is specified use: sudolikeaboss://username>@<hostname

Then, hopefully be able to configure a trigger that grabs the username and possibly hostname from the sudo command. I could then configure the sudo prompt to include username and hostname on all my hosts. The regular expression could then send just the username if I'm on a kerberos/ad connected server, or the username and hostname if not.