#!/bin/sh # reads git's request on stdin and prints credentials to stdout # this script is made for overleaf's non-standard ssh-less git # but it can be trivially modified for other git http auth # Setup: # git config --global credential.helper kasi # git config --global credential.https://git.overleaf.com/.username git set -euo pipefail # read the command from Git if [ -n "$1" ]; then cmd="$1"; else read cmd || exit 1; fi case "$cmd" in # easier on me to manually handle credentials store) ;; erase) ;; # git is fine with nothing responded to this capability*) ;; # the only command needed get) host="$(awk -F'=' '/^host=/ {print $2; exit}' <&0)" [ "$host" != "git.overleaf.com" ] && exit 0 password="$(kasi view 'university/overleaf' | awk '/^Git:/ {print $2}')" echo "username=git" echo "password=$password" ;; *) echo >&2 "Unknown command received by git-credential-kasi: $cmd" exit 1 ;; esac