Skip to content

Instantly share code, notes, and snippets.

@maxkomarychev
Last active December 9, 2019 15:38
Show Gist options
  • Save maxkomarychev/3167d7160c80985f00c58eea213b45d7 to your computer and use it in GitHub Desktop.
Save maxkomarychev/3167d7160c80985f00c58eea213b45d7 to your computer and use it in GitHub Desktop.
Authenticate `hub` from OS X keychain

(original answer mislav/hub#463 (comment))

  1. create token with necessary permissions (https://github.com/github/hub/blob/master/share/man/man1/hub.1.md#github-oauth-authentication)
  2. copy the token
  3. add token into keychain: security add-generic-password -a -s -w, for instance: security add-generic-password -a johndoe -s hub -w (you will be prompted twice for the token, just hit cmd+v and hit enter)
  4. open ~/.bash_profile with your favorite editor
  5. add alias: alias ghub='GITHUB_TOKEN=$(security find-generic-password -s -a -w) hub'
  6. reload your shell config: source ~/.bash_profile
  7. now you can use hub through alias ghub and it will be authorized with your token :)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment