Skip to content

Instantly share code, notes, and snippets.

Last active Feb 8, 2022
What would you like to do?
`.grip/` for that populates USERNAME and PASSWORD from invoking `git credential fill` with I/O through a pipe. See
# .grip/
# Uses "git credential fill" to populate USERNAME and PASSWORD
def git_credential_fill():
import subprocess
argv = ["git", "credential", "fill"]
process = subprocess.Popen(argv, text = True, stdin = subprocess.PIPE, stdout = subprocess.PIPE, stderr = subprocess.PIPE)
output = process.communicate(input = "protocol=https\\n")[0].strip()
map = dict(item.split("=") for item in output.splitlines())
return (map["username"], map["password"])
(USERNAME, PASSWORD) = git_credential_fill()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment