initial commit
This commit is contained in:
commit
e887d8bc7d
13 changed files with 490 additions and 0 deletions
16
home-manager/git/git-identity
Normal file
16
home-manager/git/git-identity
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# get each set of usernames from the git config
|
||||
IDENTITIES=$(git config --global --name-only --get-regexp "user.*..name" | sed -e 's/^user.//' -e 's/.name$//')
|
||||
# filter them with fzf
|
||||
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
|
||||
|
||||
# set the id locally in each repo (eg in the repo's .git/config)
|
||||
git config user.name "$(git config user.${ID}.name)"
|
||||
git config user.email "$(git config user.${ID}.email)"
|
||||
Loading…
Add table
Add a link
Reference in a new issue