#!/usr/bin/env bash IDENTITIES=$(git config --global --name-only --get-regexp "user.*..name" | sed -e 's/^user.//' -e 's/.name$//') ID=$(echo "${IDENTITIES}" | fzf -e -1 +m -q "$1") if ! git config --global --get-regexp "user.${ID}.name" > /dev/null; then echo "Please use a valid git identity Options:" git config --global --name-only --get-regexp "user.*..name" | sed -e 's/^user.//' -e 's/.name$//' -e 's/^/\t/' exit 1 fi git config user.name "$(git config user.${ID}.name)" git config user.email "$(git config user.${ID}.email)" echo "Name: $(git config user.name)" echo "Email: $(git config user.email)"