Skip to content

Instantly share code, notes, and snippets.

@hryamzik
Last active September 16, 2015 19:21
Show Gist options
  • Save hryamzik/3fad9a3c0a0c2d5d4664 to your computer and use it in GitHub Desktop.
Save hryamzik/3fad9a3c0a0c2d5d4664 to your computer and use it in GitHub Desktop.
#!/bin/bash
repo="$(git config --get remote.origin.url|sed -E 's/http(s)?:[/]{2}([^/]+)[/]/git@\2:/')"
test -n "$repo" || repo="$PWD"
if ! security find-generic-password -gw -s "$repo" -a "ansible-vault" -D "ansible vault"
then
echo "Enter password for $repo:" 1>&2
read pass
security add-generic-password -a "ansible-vault" -s "$repo" -w "$pass" -D "ansible vault" -T ""
echo $pass
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment