Repository navigation
Expand file tree
/
Copy pathsetup_git.sh
More file actions
59 lines (53 loc) · 1.51 KB
/
Copy pathsetup_git.sh
File metadata and controls
59 lines (53 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/bash
printf "
Setting up git...
"
# Creates SSH key and sets up git config
if ssh -q git@github.com; [ $? -eq 255 ]; then
# GitHub SSH failed, so create a new SSH key
printf "
Creating SSH key...
"
read -rp "Enter your e-mail: " ssh_email
printf "
"
ssh-keygen -t ed25519 -C "$ssh_email"
printf "
"
printf "Adding ssh key to ssh-agent
"
eval "$(ssh-agent -s)"
ssh-add --apple-use-keychain ~/.ssh/id_ed25519
printf "
👋 Copying SSH key to clipboard. You can copy the key again by running 'pbcopy <~/.ssh/id_ed25519.pub'
"
pbcopy <~/.ssh/id_ed25519.pub
printf "
✅ Done.
👋 Paste it in GitHub https://github.com/settings/keys
"
read -p "Set up git config? (y,n): " doit
printf "
"
case $doit in y | Y)
read -p "👋 Enter your first name (no spaces): " fn
read -p "👋 Enter your last name (no spaces): " ln
git config --global credential.helper store
git config --global user.name "$fn $ln"
git config --global user.email "$ssh_email"
git config --global core.pager cat
git config --global core.editor "nvim"
git config --global pull.rebase true
git config --global fetch.prune true
git config --global push.autoSetupRemote true
git config --global mergetool.keepBackup false
git config --global merge.tool vscode
git config --global mergetool.vscode.cmd "code --wait --merge \$REMOTE \$LOCAL \$BASE \$MERGED"
;;
n | N) echo "Skipping" ;;
esac
else
printf "
SSH is already configured. Nothing to do.
"
fi