-
Notifications
You must be signed in to change notification settings - Fork 2
/
bootstrap.sh
executable file
·61 lines (48 loc) · 1.51 KB
/
bootstrap.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
#!/bin/bash
echo " __ __ _____ __ "
echo " ____/ /___ / /_/ __(_) /__ _____ "
echo " / __ / __ \/ __/ /_/ / / _ \/ ___/ "
echo " / /_/ / /_/ / /_/ __/ / / __(__ ) "
echo " \__,_/\____/\__/_/ /_/_/\___/____/ "
echo "____________________________________________"
echo
echo "Installing dotfiles into your home directory"
echo
########## Functions
warn() {
echo "$1" >&2
}
die() {
warn "$1"
exit 1
}
lnif() {
ln -sf $1 $2
}
########## Variables
endpath="$HOME/dotfiles" # dotfiles directory
today=`date +%F-%T`
backupdir="$HOME/old.dotfiles.$today"
# list of files/folders to symlink in homedir
dotfiles="bashrc bash_profile gitattributes gitconfig tmux.conf gemrc ackrc irbrc inputrc gitignore"
##########
echo "thanks for installing this dotfile"
# change to the dotfiles directory
echo "changing to the $endpath directory"
cd $endpath
if [ -e $endpath/.git ]; then
echo "getting the latest version of your dotfiles"
cd $endpath && git pull
echo "...update done"
fi
# move any existing dotfiles in homedir to a timestamped backup directory, then create symlinks
mkdir $backupdir
for dotfile in $dotfiles; do
# Backup existing dotfiles stuff
echo "backing up $dotfile dotfiles to $backupdir"
[ -e $dotfile ] && [ ! -L $file ] && mv $HOME/.$dotfiles $backupdir
echo "Creating symlink to $file in home directory."
lnif $endpath/$dotfile $HOME/.$dotfile
done
source $HOME/.bashrc
echo "your new dotfiles has been sourced... BAM!"