feat(git): configure age textconv
This commit is contained in:
parent
ddae1cfb1e
commit
7055986bb2
2 changed files with 34 additions and 34 deletions
|
@ -59,3 +59,6 @@
|
|||
clean = git-age clean -- %f
|
||||
smudge = git-age smudge -- %f
|
||||
required = true
|
||||
|
||||
[diff "age"]
|
||||
textconv = cat
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/opt/homebrew/Cellar/bash/5.2.21/bin/bash
|
||||
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# rbw git-credential helper
|
||||
# Based on https://github.com/lastpass/lastpass-cli/blob/master/contrib/examples/git-credential-lastpass
|
||||
|
||||
|
@ -9,39 +9,36 @@
|
|||
# 1. Put this somewhere in your path.
|
||||
# 2. git config --global credential.helper rbw
|
||||
|
||||
declare -A params
|
||||
set -f
|
||||
|
||||
if [ "x$1" == "xget" ]; then
|
||||
read line
|
||||
while [ -n "$line" ]; do
|
||||
key=${line%%=*}
|
||||
value=${line#*=}
|
||||
params[$key]=$value
|
||||
read line
|
||||
[ "$1" = get ] || exit
|
||||
|
||||
while read -r line; do
|
||||
case $line in
|
||||
protocol=*)
|
||||
protocol=${line#*=} ;;
|
||||
host=*)
|
||||
host=${line#*=} ;;
|
||||
username=*)
|
||||
user=${line#*=} ;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ "x${params['protocol']}" != "xhttps" ]; then
|
||||
exit
|
||||
fi
|
||||
output=
|
||||
#shellcheck disable=2154
|
||||
for arg in \
|
||||
"${protocol:+$protocol://}$host" \
|
||||
"$host" \
|
||||
"${host2=${host%.*}}" \
|
||||
"${host2#*.}"
|
||||
do
|
||||
# exit on first good result
|
||||
[ -n "$user" ] && output=$(rbw get --full "$arg" "$user") && break
|
||||
output=$(rbw get --full "$arg") && break
|
||||
done || exit
|
||||
|
||||
if [ -z "${params["host"]}" ]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
rbw ls > /dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Please login to rbw to use git credential helper" > /dev/stderr
|
||||
exit
|
||||
fi
|
||||
|
||||
user=`rbw get --full ${params["host"]} | grep "Username:" | cut -d' ' -f2-`
|
||||
pass=`rbw get ${params["host"]}`
|
||||
|
||||
if [ "x$user" == "x" ] || [ "x$pass" == "x" ]; then
|
||||
echo "Couldn't find host in rbw DB." > /dev/stderr
|
||||
exit
|
||||
fi
|
||||
|
||||
echo username=$user
|
||||
echo password=$pass
|
||||
fi
|
||||
printf '%s\n' "$output" | sed -n '
|
||||
1{ s/^/password=/p }
|
||||
s/^Username: /username=/p
|
||||
s/^URI: /host=/p
|
||||
'
|
||||
|
|
Loading…
Reference in a new issue