-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_env.sh
More file actions
executable file
·49 lines (40 loc) · 1.33 KB
/
setup_env.sh
File metadata and controls
executable file
·49 lines (40 loc) · 1.33 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
46
47
48
49
#!/usr/bin/env bash
# Get the directory of this script
DIR="$(pwd)"
# --- Symlink Function ---
create_symlink() {
local source=$1
local destination=$2
if [ -L "${destination}" ]; then
echo "Symlink already exists: ${destination}"
elif [ -e "${destination}" ]; then
echo "File exists at ${destination}, backing up and creating symlink..."
mv "${destination}" "${destination}.backup.$(date +%Y%m%d_%H%M%S)"
ln -s "${source}" "${destination}"
echo "Created symlink: ${destination} (old file backed up)"
else
ln -s "${source}" "${destination}"
echo "Created symlink: ${destination}"
fi
}
# --- Create Directories ---
mkdir -p "$HOME/.config"
mkdir -p "$HOME/projects"
# --- Symlink Shared Files ---
create_symlink "$DIR/.zshrc" "$HOME/.zshrc"
create_symlink "$DIR/shared/.tmux.conf" "$HOME/.tmux.conf"
# --- Symlink Neovim and Tmux Configuration ---
create_symlink "$DIR/nvim" "$HOME/.config/nvim"
create_symlink "$DIR/shared/tmux" "$HOME/.config/tmux"
# --- Symlink OS-specific Files ---
if [[ "$(uname)" == "Darwin" ]]; then
# macOS
create_symlink "$DIR/macos/.zprofile" "$HOME/.zprofile"
fi
if [[ "$(uname)" == "Linux" ]]; then
# Linux
create_symlink "$DIR/linux/.zprofile" "$HOME/.zprofile"
fi
echo ""
echo "Dotfiles installation complete!"
echo "Backed up files are saved with .backup.TIMESTAMP extension"