-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
39 lines (34 loc) · 1.1 KB
/
install.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
39
#!/bin/bash
# Cross-platform compatibility for home directory
if [ "$(uname)" == "Darwin" ]; then
DOTFILES_DIR="$HOME/.dotfiles"
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
DOTFILES_DIR="$HOME/.dotfiles"
elif [ "$(expr substr $(uname -s) 1 10)" == "MINGW32_NT" ]; then
DOTFILES_DIR="/c/Users/$USER/.dotfiles"
else
echo "Unsupported operating system. Exiting..."
exit 1
fi
# List of dotfiles to be linked
DOTFILES=("vimrc" "aliases" "bash_profile" "bash_prompt" "bashrc")
# Function to create symbolic links
link_dotfiles() {
for dotfile in "${DOTFILES[@]}"; do
if [ -f "$HOME/.$dotfile" ]; then
echo "Backing up existing .$dotfile to $HOME/dotfile_backup/"
mkdir -p "$HOME/dotfile_backup"
mv "$HOME/.$dotfile" "$HOME/dotfile_backup/"
fi
echo "Creating symlink for .$dotfile"
ln -s "$DOTFILES_DIR/$dotfile" "$HOME/.$dotfile"
done
}
# Main installation process
install_dotfiles() {
echo "Installing dotfiles..."
link_dotfiles
echo "Dotfiles installation complete!"
}
# Execution
install_dotfiles