-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·45 lines (38 loc) · 1.45 KB
/
setup.sh
File metadata and controls
executable file
·45 lines (38 loc) · 1.45 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
#!/bin/bash
readonly REPO_OWNER="seyLu"
readonly REPO_NAME="scripts"
readonly REPO_URL="https://github.com/${REPO_OWNER}/${REPO_NAME}.git"
readonly REPO_PARENT_DIR="${HOME}/Documents/repos"
readonly REPO_DIR="${REPO_PARENT_DIR}/${REPO_NAME}"
readonly ENTRY_POINT="${REPO_DIR}/bash/__init__"
if [[ ! -d "${REPO_PARENT_DIR}" ]]; then
mkdir "${REPO_PARENT_DIR}"
fi
cd "${REPO_PARENT_DIR}" || exit
if [[ -d "${REPO_DIR}/.git" ]]; then
printf '%s\n' "Directory '${REPO_DIR}' is a git repository. Pulling latest changes..."
cd "${REPO_DIR}" || exit
git pull
else
printf '%s\n' "Directory '${REPO_DIR}' is not a git repository. Cloning..."
git clone "${REPO_URL}"
fi
if [[ ! -f ~/.bashrc ]]; then
touch ~/.bashrc
printf '%s\n' "#!/bin/bash" >>~/.bashrc
fi
if ! grep -Fq '[[ -z "$_SCRIPTS_PATH}" ]] &>/dev/null' ~/.bashrc; then
{
echo
printf '%s\n' "# Initialize External Scripts"
printf '%s\n' "source \"${ENTRY_POINT}\""
printf '%s\n' "# Enhanced colorful prompt with git branch"
printf '%s\n' 'export PS1="\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[01;31m\] \$(parse_git_branch)\[\033[00m\]\n\$ "'
echo
} >>~/.bashrc
# shellcheck source=/dev/null
source "${ENTRY_POINT}"
printf '%s\n' "Setup complete! Open a new terminal to start using your custom aliases and scripts."
else
printf '%s\n' "No setup needed. Your custom aliases and scripts are already configured."
fi