-
Notifications
You must be signed in to change notification settings - Fork 1
/
create-symlinks
executable file
·39 lines (31 loc) · 1.26 KB
/
create-symlinks
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
#!/usr/bin/env bash
dotfiles=(".zshrc" ".bashrc" ".Xresources" ".gitconfig" "bin" ".zsh" ".zshenv" ".xprofile" ".bash_profile" ".pylintrc" ".gitignore_global" ".Xresources.d" ".xinitrc" ".profile" ".zprofile" ".mailcap" ".doom.d" ".emacs.d" ".vimrc")
configs=("user-dirs.dirs" "rofi" "bspwm" "sxhkd" "aliases" "gtk-3.0" "gtk-2.0" "aerc" "mpd" "nvim" "tmux" "kitty" "Code" "ideavim" "wezterm")
PWD=$(pwd)
backup_dir="$HOME/old_dotfiles"
backup(){
mkdir -p "$backup_dir"
mkdir -p "$backup_dir/.config"
for file in "${dotfiles[@]}"; do
if [[ -f "$HOME/$file" || -d "$HOME/$file" ]]; then
echo "Backing up ${HOME}/${file}"
mv "$HOME/$file" "$backup_dir/$file"
fi
done
for file in "${configs[@]}"; do
if [[ -f "$HOME/.config/$file" || -d "$HOME/.config/$file" ]]; then
echo "Backing up ${HOME}/.config/${file}"
mv "$HOME/.config/$file" "$backup_dir/.config/$file"
fi
done
}
backup
for file in "${dotfiles[@]}"; do
echo "Creating symlink ${HOME}/${file}"
ln -sf "${PWD}/${file}" "${HOME}/${file}"
done
mkdir -p ~/.config
for file in "${configs[@]}"; do
echo "Creating symlink ${HOME}/.config/${file}"
ln -sf "${PWD}/.config/${file}" "${HOME}/.config/${file}"
done