-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpatch.sh
More file actions
executable file
·23 lines (19 loc) · 839 Bytes
/
patch.sh
File metadata and controls
executable file
·23 lines (19 loc) · 839 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/sh
config_file="$1/gitconfig"
include_section="[include]"
include_line="path = archyGitAliases"
# Check if the gitconfig file exists
if [[ ! -f "$config_file" ]]; then
# Create the gitconfig file if it doesn't exist
sudo touch "$config_file"
echo "Created $config_file"
fi
# Check if the include section already exists in the gitconfig file
if ! awk -F "=" -v section="$include_section" '$1 == section { found = 1; exit } END { exit !found }' "$config_file"; then
# Add the include section to the gitconfig file
echo -e "\n$include_section" >> "$config_file"
fi
# Check if the alias line already exists in the include section
if ! awk -F "=" -v section="$include_line" '$1 == section { found = 1; exit } END { exit !found }' "$config_file"; then
sed -i "/^\[include\]$/a\ path = archyGitAliases" /etc/gitconfig
fi