Skip to content

Instantly share code, notes, and snippets.

@ulayera
Last active October 25, 2022 20:19
Show Gist options
  • Save ulayera/139c3104c57192311015171497c90467 to your computer and use it in GitHub Desktop.
Save ulayera/139c3104c57192311015171497c90467 to your computer and use it in GitHub Desktop.
R='\033[0;31m'
G='\033[0;32m'
NC='\033[0m'
NEW_EMAIL=$(cat ~/.ssh/id_ed25519_secondary.pub | awk '{ print $3}')
echo "${G}Current: $(cat ~/.ssh/id_ed25519.pub | awk '{ print $3}')"
echo "${R}New: $NEW_EMAIL${NC}"
printf 'Is this a good question (y/n)? '
read answer
if [ "$answer" != "${answer#[Yy]}" ] ;then
mv ~/.ssh/id_ed25519 ~/.ssh/temp
mv ~/.ssh/id_ed25519.pub ~/.ssh/temp.pub
mv ~/.ssh/id_ed25519_secondary ~/.ssh/id_ed25519
mv ~/.ssh/id_ed25519_secondary.pub ~/.ssh/id_ed25519.pub
mv ~/.ssh/temp ~/.ssh/id_ed25519_secondary
mv ~/.ssh/temp.pub ~/.ssh/id_ed25519_secondary.pub
git config --global --add user.email "$NEW_EMAIL"
echo "${G}New set: $(cat ~/.ssh/id_ed25519.pub | awk '{ print $3}')${NC}"
else
echo "${R}Nothing done"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment