-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·70 lines (53 loc) · 1.78 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#! /usr/bin/env bash
set -eu pipefail
install_dotfiles () {
dotfiles=( asdfrc default-gems gemrc tmux.conf zshrc aliases gitignore solargraph.yml reek.yml gitattributes wezterm.lua XCompose )
for dotfile in "${dotfiles[@]}";
do
ln_file_to_home_directory "$dotfile"
done
}
install_config () {
local source_full_path="$HOME/dotfiles/config/$1"
local target_full_path="$HOME/.config/$1"
if [ -e "$target_full_path/.dotfile" ]; then
echo "Removing existing $target_full_path folder"
rm -rf "$target_full_path"
elif [ -d "$target_full_path" ]; then
echo "Backing up existing $target_full_path folder"
mv "$target_full_path" "$target_full_path"_backup_"$(date +%s%3N)"
fi
mkdir -p "$target_full_path"
touch "$target_full_path"/.dotfile
ln -s "${source_full_path}"/* "${target_full_path}/"
}
ln_file_to_home_directory () {
source_full_path="$HOME/dotfiles/$1"
target_full_path=${2:-"$HOME/.$1"}
if [ -L "$target_full_path" ]; then
echo "Removing existing symlink $target_full_path"
rm "$target_full_path"
fi
if [ -e "$target_full_path" ]; then
echo "backing up $target_full_path"
mv "$target_full_path" "${target_full_path}_backup_$(date +%s)"
fi
ln -s "$source_full_path" "$target_full_path"
}
install_dunst_conf () {
mkdir -p "$HOME/.config/dunst"
wget "https://raw.githubusercontent.com/catppuccin/dunst/b0b838d38f134136322ad3df2b6dc57c4ca118cf/src/macchiato.conf" -O ~/.config/dunst/dunstrc
}
main () {
if [ ! -d "$HOME/dotfiles" ]; then
git clone https://github.com/rhiroyuki/dotfiles.git "$HOME/dotfiles"
fi
install_dotfiles
for dir in "$HOME/dotfiles/config"/*; do
echo "Installing $(basename "$dir")"
install_config "$(basename "$dir")"
done
install_dunst_conf
echo "Finished installation"
}
main