-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake.sh
executable file
·58 lines (53 loc) · 1.82 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
50
51
52
53
54
55
56
57
58
#!/bin/bash
# TODO: Automatically generate $FILES var.
# TODO: Ask user if they want to copy each dotfile
# TODO: Add options for config files, ie .i3, .vim
# TODO: Add a dry run option
# home directory.
HOME="$( cd ~ && pwd )"
# dotfiles directory. This should be current directory
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# directory for old dotfiles. This will be at root
BACKUPDIR="$HOME/dotfiles_backup"
# All the files that shoud be backed up.
FILES=".vimrc .bashrc .bash_aliases .Xresources"
CONFIGS="i3"
FIRST_INSTALL=""
BACKGROUND=NC27TKc.jpg
while [[ $FIRST_INSTALL != "y" && $FIRST_INSTALL != "n" ]]
do
read -p "Is this your first install? (y/n): " $FIRST_INSTALL
if [[ $FIRST_INSTALL != "y" && $FIRST_INSTALL != "n" ]]
then
printf "Please enter only 'y' or 'n'"
fi
done
if [[ $FIRST_INSTALL == "y" ]]
then
printf "Escalating to SU for to move to /usr/share folder \n"
sudo cp $BACKGROUND /usr/share/backgrounds/
printf "Linking i3exit"
ln -s $DIR/i3/i3exit /usr/local/bin/
fi
# TODO: Ask user if they want to backup a given dot file, and if they do, add a
# version number.
# Backup existing dot files, then remove old file and create a new symlink to
# file in dotfiles dir
echo "Creating $BACKUPDIR for backup of any existing dotfiles in home dir"
mkdir -p $BACKUPDIR
for file in $FILES; do
if [ -e $HOME/$file ] && [ ! -h $HOME/$file ]
then
echo "Backing up $file"
mv -i $HOME/$file $BACKUPDIR
fi
rm $HOME/$file
ln -s $DIR/$file $HOME/$file
done
# Do the same as above for ~/.config/ files and directories
for file in $CONFIGS; do
echo "Moving ~/.config/ files or dirs from ~/.config/ to $~/.config/backup"
mv -i ~/.config/$file ~/.config/backup
echo "Creating symlinks to $file in ~/.config/"
ln -s $DIR/$file ~/.config/$file
done