-
Notifications
You must be signed in to change notification settings - Fork 0
/
git.sh
executable file
·38 lines (30 loc) · 995 Bytes
/
git.sh
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
#!/bin/bash
VERSION="0.8"
echo ""
echo -e "\e[32mGit script v$VERSION\e[0m"
file_url="https://raw.githubusercontent.com/mohitxskull/scripts/main/src/git.src.sh"
self_url="https://raw.githubusercontent.com/mohitxskull/scripts/main/git.sh"
store="$HOME/.sbs"
lu="$store/lu"
if [ ! -d "$store" ]; then
mkdir "$store"
fi
if [ ! -f "$lu" ]; then
touch "$lu"
echo 0 >"$lu"
fi
# self update -s flag
if [ "$1" = "-s" ]; then
echo "" && echo -e "\e[32mUpdating self...\e[0m" && echo ""
curl -H "Cache-Control: no-cache" -s "$self_url" >"$0"
chmod +x "$0"
exit
fi
# -u flag to update file
if [ ! -f "$store/$(basename "$file_url")" ] || [ "$(date +%s)" -gt "$(($(cat "$lu") + 86400))" ] || [ "$1" = "-u" ]; then
echo "" && echo -e "\e[32mUpdating file...\e[0m" && echo ""
# use -H to avoid caching
curl -H "Cache-Control: no-cache" -s "$file_url" >"$store/$(basename "$file_url")"
echo "$(date +%s)" >"$lu"
fi
bash "$store/$(basename "$file_url")" "$@"