-
Notifications
You must be signed in to change notification settings - Fork 0
/
make.sh
49 lines (40 loc) · 1.48 KB
/
make.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
#!/bin/bash
############################
# .make.sh
# This script creates symlinks from the home directory to any desired dotfiles in ~/dotfiles
############################
########## Variables
DOTFILES=~/dotfiles # dotfiles directory
BACKUPDOTFILES=~/dotfiles_old
GREEN="\033[1;32m"
YELLOW="\033[1;33m"
BLUE="\033[1;34m"
NOCOLOR="\033[0m"
CURRENT_TIME=$(date "+%Y.%m.%d-%H.%M.%S")
BACKUPDOTFILES_CT=$BACKUPDOTFILES.$CURRENT_TIME
# old dotfiles backup directory
files=(zshrc ohmyzsh pure ohmyzsh-custom ohmyzsh-plugins) # list of files/folders to symlink in homedir
##########
echo "${YELLOW}Updating submodules${NOCOLOR}"
git submodule update --remote --merge
echo "${GREEN}...done${NOCOLOR}"
echo -e "\n\n"
# create dotfiles_old in homedir
echo "${YELLOW}Creating $BACKUPDOTFILES_CT for backup of any existing dotfiles in ~${NOCOLOR}"
mkdir -p "$BACKUPDOTFILES_CT"
echo "${GREEN}...done${NOCOLOR}"
echo -e "\n\n"
# change to the dotfiles directory
echo "${YELLOW}Changing to the $DOTFILES directory${NOCOLOR}"
cd $DOTFILES || exit
echo "${GREEN}...done${NOCOLOR}"
echo -e "\n\n"
# move any existing dotfiles in homedir to dotfiles_old directory, then create symlinks
for file in "${files[@]}"; do
echo "${BLUE}Moving any existing dotfiles from ~ to $BACKUPDOTFILES_CT${NOCOLOR}"
cp -LR ~/."$file" "$BACKUPDOTFILES_CT"
rm -f ~/."$file"
echo "${BLUE}Creating symlink to $file in home directory.${NOCOLOR}"
ln -sfh $DOTFILES/"$file" ~/."$file"
echo
done