-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·83 lines (66 loc) · 2.26 KB
/
install.sh
File metadata and controls
executable file
·83 lines (66 loc) · 2.26 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/env bash
CMD="$1"
# Get current dir (so run this script from anywhere)
DOTFILES_DIR=$(pwd)
BACKUP_DIR=~/.dotfiles.orig
dotfiles=(.zshrc .ssh .aliases .bashrc .vimrc .Xresources .dircolors .git-templates)
dotfiles_config=(kitty git i3 i3status fish )
# Make utilities available
PATH="$DOTFILES_DIR/bin:$PATH"
# Update dotfiles itself first
#if is-executable git -a -d "$DOTFILES_DIR/.git"; then git --work-tree="$DOTFILES_DIR" --git-dir="$DOTFILES_DIR/.git" pull origin master; fi
# Bunch of symlinks
# Package managers & packagesvg
install() {
# Backup config.
if ! [ -f $BACKUP_DIR/check-backup.txt ]; then
mkdir -p $BACKUP_DIR/.config
cd $BACKUP_DIR
touch check-backup.txt
# Backup to ~/.dotfiles.orig
for dots in "${dotfiles[@]}"
do
/bin/cp -rf ~/${dots} $BACKUP_DIR &> /dev/null
done
#Backup some folder in ~/.config to ~/.dotfiles.orig/.config
for dots_conf in "${dotfiles_config[@]//./}"
do
/bin/cp -rf ~/.config/${dots_conf} $BACKUP_DIR/.config &> /dev/null
done
# Backup again with Git.
git init &> /dev/null
git add -u &> /dev/null
git add . &> /dev/null
git commit -m "Backup original config on `date '+%Y-%m-%d %H:%M'`" &> /dev/null
# Output.
echo -e $blue"Your config is backed up in "$BACKUP_DIR"\n" >&2
echo -e $red"Please do not delete check-backup.txt in .dotfiles.orig folder."$white >&2
echo -e "It's used to backup and restore your old config.\n" >&2
fi
# Install config.
for dots in "${dotfiles[@]}"
do
/bin/rm -rf ~/${dots}
/bin/ln -fs "$DOTFILES_DIR/${dots}" ~/
done
#Install config to ~/.config.
mkdir -p ~/.config
for dots_conf in "${dotfiles_config[@]}"
do
/bin/rm -rf ~/.config/${dots_conf[@]//./}
/bin/ln -fs "$DOTFILES_DIR/.config/${dots_conf}" ~/.config/${dots_conf[@]//./}
done
echo -e $blue"New dotfiles is installed!\n"$white >&2
echo "There may be some errors when Terminal is restarted." >&2
}
case "$CMD" in
-i)
install
;;
-r)
uninstall
;;
*)
echo "Command not found. Commands -i install and -r unistall" >&2
exit 1
esac