Skip to content

Commit f5cdd2c

Browse files
Add Git Setup
1 parent 765f564 commit f5cdd2c

5 files changed

Lines changed: 242 additions & 5 deletions

File tree

astro.config.mjs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,31 +11,32 @@ export default defineConfig({
1111
{
1212
icon: 'github',
1313
label: 'GitHub',
14-
href: 'https://github.com/marcosborgesphd/mac-setup'
14+
href: 'https://github.com/marcosborgesphd/mac-setup',
1515
},
1616
{
1717
icon: 'youtube',
1818
label: 'YouTube',
19-
href: 'https://www.youtube.com/@MarcosBorgesPhD'
19+
href: 'https://www.youtube.com/@MarcosBorgesPhD',
2020
},
2121
{
2222
icon: 'linkedin',
2323
label: 'LinkedIn',
24-
href: 'https://www.linkedin.com/in/marcosborgesphd'
24+
href: 'https://www.linkedin.com/in/marcosborgesphd',
2525
},
2626
],
2727
sidebar: [
2828
{
2929
label: 'Start Here',
3030
items: [
3131
{ label: 'Getting Started', slug: 'index'},
32-
{ label: 'About Marcos Borges', slug: 'about/marcos-borges' }
32+
{ label: 'About Marcos Borges', slug: 'about/marcos-borges' },
3333
],
3434
},
3535
{
3636
label: 'Guides',
3737
items: [
38-
{ label: 'First Steps', slug: 'guides/first-steps' }
38+
{ label: 'First Steps', slug: 'guides/first-steps' },
39+
{ label: 'Git Setup', slug: 'guides/git-setup' },
3940
],
4041
}
4142
],

install

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
#!/usr/bin/env bash
2+
# Mac-Setup CLI
3+
#
4+
# Copyright (c) 2025 Marcos Borges
5+
# https://marcosborges.phd
6+
#
7+
readonly MAC_SETUP_DOC="https://marcosborgesphd.github.io/mac-setup"
8+
readonly VERSION="0.0.1"
9+
readonly PREFIX="${HOME}"
10+
11+
readonly CR='\033[91m'
12+
readonly CG='\033[92m'
13+
readonly CM='\033[95m'
14+
readonly NC='\033[0m'
15+
16+
set -euo pipefail
17+
18+
usage() {
19+
cat <<'EOF'
20+
Usage: install [options]
21+
Mac Development Setup CLI tool.
22+
23+
Options
24+
-h, --help Display this help message
25+
-v, --version Show version details
26+
git Install and set up Git
27+
gitconfig Set up Git
28+
EOF
29+
}
30+
31+
error() {
32+
usage
33+
printf "${CR}\nError:${NC} Illegal option!\n"
34+
}
35+
36+
abort() {
37+
printf "\n${CR}Aborted by user.${NC}\n"
38+
exit 1
39+
}
40+
trap abort SIGINT # Ctrl-C
41+
42+
version() {
43+
printf "Mac-Setup ${VERSION}\n"
44+
}
45+
46+
wait_for_user() {
47+
printf "\nPress ${CG}[ENTER]${NC} to continue, "
48+
printf "or ${CR}[any other key]${NC} to abort.\n"
49+
50+
read -rsn 1 key
51+
if [[ ${key} != "" ]]; then
52+
abort
53+
fi
54+
}
55+
56+
wait_for_sudo() {
57+
# Request sudo password
58+
if ! sudo -vn 2>/dev/null; then
59+
printf "\n${CM}Requesting sudo privileges for ${USER}...${NC}\n"
60+
sudo -v
61+
fi
62+
63+
# Abort if no sudo privileges
64+
if ! sudo -vn 2>/dev/null; then
65+
printf "Sudo privileges are required to run this script. "
66+
printf "${CR}Aborting.${NC}\n"
67+
exit 1
68+
fi
69+
70+
printf "\n${CG}Sudo privileges are active for this script.${NC}\n\n"
71+
}
72+
73+
brew_init() {
74+
if [[ "$(/usr/bin/uname -m)" == "arm64" ]]; then
75+
HOMEBREW='/opt/homebrew' # ARM
76+
else
77+
HOMEBREW='/usr/local' # Intel
78+
fi
79+
80+
if [[ -x "${HOMEBREW}/bin/brew2" ]]; then
81+
eval "$(${HOMEBREW}/bin/brew shellenv)"
82+
else
83+
printf "\nInstall Homebrew and then re-run this script.\n"
84+
printf "${CM}Learn more:${NC} ${MAC_SETUP_DOC}\n\n"
85+
printf "${CR}Homebrew is required to continue.${NC}\n"
86+
exit 1
87+
fi
88+
}
89+
90+
brew_update() {
91+
printf "${CM}Updating Homebrew...${NC}\n"
92+
brew_init
93+
brew update
94+
}
95+
96+
git_install() {
97+
printf "${CM}Installing Git...${NC}\n"
98+
brew install git || true
99+
printf "\n${CG}Git installation completed successfully.${NC}\n\n"
100+
}
101+
102+
git_config() {
103+
printf "${CM}Configuring Git...${NC}\n"
104+
105+
printf "Enter your Git username: "
106+
read -r GIT_USER_NAME
107+
108+
printf "Enter your Git email: "
109+
read -r GIT_USER_EMAIL
110+
111+
printf "\n${CM}Confirming your Git configuration:${NC}\n"
112+
printf " Username: ${GIT_USER_NAME}\n"
113+
printf " Email: ${GIT_USER_EMAIL}\n"
114+
115+
wait_for_user
116+
117+
git config --global user.name "${GIT_USER_NAME}"
118+
git config --global user.email "${GIT_USER_EMAIL}"
119+
120+
git config --global color.ui true
121+
git config --global color.status.changed "yellow bold"
122+
git config --global color.status.untracked "red bold"
123+
git config --global color.status.added "green bold"
124+
git config --global color.status.updated "cyan bold"
125+
git config --global color.status.branch "magenta bold"
126+
git config --global color.status.header "cyan bold"
127+
128+
printf "\n${CG}Git configuration completed.${NC}\n\n"
129+
}
130+
131+
# --- Check for no arguments ---
132+
if [[ $# -eq 0 ]]; then
133+
usage
134+
exit 1
135+
fi
136+
137+
# --- Parse arguments ---
138+
for arg in "$@"; do
139+
case "${arg}" in
140+
-v|--version)
141+
version;
142+
exit 0
143+
;;
144+
-h|--help)
145+
usage
146+
exit 0
147+
;;
148+
git)
149+
brew_update
150+
git_install
151+
git_config
152+
;;
153+
gitconfig)
154+
git_config
155+
;;
156+
--|-*|*)
157+
error
158+
exit 1
159+
;;
160+
esac
161+
done

src/assets/git.png

2.79 KB
Loading
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
---
2+
title: Git Setup
3+
description: Install and set up Git username, email, and terminal colors.
4+
---
5+
import { Steps, Aside } from '@astrojs/starlight/components';
6+
7+
![Git](../../../assets/git.png)
8+
9+
[Git](https://git-scm.com) is a free and open source distributed version control system.
10+
11+
## Installing Git via Mac-Setup CLI
12+
13+
```bash
14+
bash <(curl -fsSL raw.githubusercontent.com/marcosborgesphd/mac-setup/main/install) git
15+
```
16+
17+
## Installing Git manually
18+
19+
<Steps>
20+
21+
1. Set up Homebrew environment
22+
23+
Paste that in the terminal prompt:
24+
25+
```bash
26+
if [[ "$(/usr/bin/uname -m)" == "arm64" ]]; then
27+
HOMEBREW='/opt/homebrew' # ARM
28+
else
29+
HOMEBREW='/usr/local' # Intel
30+
fi
31+
eval "$(${HOMEBREW}/bin/brew shellenv)"
32+
```
33+
34+
2. Install Git using Homebrew
35+
36+
```bash
37+
brew install git
38+
```
39+
40+
3. Set Git username and email
41+
42+
```bash
43+
git config --global user.name "Your Name"
44+
git config --global user.email "your@email.com"
45+
```
46+
47+
<Aside type="note">
48+
Remember to replace the placeholders with your own name and email.
49+
</Aside>
50+
51+
4. Set Git terminal colors for dark and light mode
52+
53+
```bash
54+
git config --global color.ui true
55+
git config --global color.status.changed "yellow bold"
56+
git config --global color.status.untracked "red bold"
57+
git config --global color.status.added "green bold"
58+
git config --global color.status.updated "cyan bold"
59+
git config --global color.status.branch "magenta bold"
60+
git config --global color.status.header "cyan bold"
61+
```
62+
63+
5. Check Git configuration
64+
65+
```bash
66+
git config --global --list
67+
```
68+
69+
</Steps>

src/content/docs/index.mdx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,9 @@ Over the years, I've experimented with countless tools and configurations. This
1515
href="/mac-setup/guides/first-steps/"
1616
description="Install and set up Xcode, Command Line Tools, and Homebrew."
1717
/>
18+
19+
<LinkCard
20+
title="Git Setup"
21+
href="/mac-setup/guides/git-setup/"
22+
description="Install and set up Git username, email, and terminal colors."
23+
/>

0 commit comments

Comments
 (0)