-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
60 lines (48 loc) · 1.71 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
#!env bash
# Find dotfiles directory path
DOTFILES_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Register the execution date for backups
date_suffix=$(date +_%F-%T-%N)
if [ ! -d "$DOTFILES_DIR/bash-it" ]; then
echo "Download and configure bash-it..."
git clone -q --depth=1 https://github.com/bash-it/bash-it.git "$DOTFILES_DIR/bash-it"
fi
# Make symlink for a bunch of files.
for file in $(find $DOTFILES_DIR -name bash_profile -o -name bashrc -o -name inputrc -o -name gitconfig -o -name emacs -type f); do
# Get the filename from path
target=$(basename $file)
if [ -f ~/$target ] && [ ! -L ~/$target ]; then
# Backup the existing file before linking.
mv ~/$target ~/$target$date_suffix
fi
# Makes the symlink to dotfile.
ln -sfv "$file" ~/.$target
done
unset target
# Make symlink for Vagrant.
if [ ! -d "$HOME/.vagrant.d" ]; then
mkdir "$HOME/.vagrant.d"
fi
target="$HOME/.vagrant.d/Vagrantfile"
if [ -f $target ] && [ ! -L $target ]; then
# Backup the existing file before linking.
mv $target $target$date_suffix
fi
ln -sfv "$DOTFILES_DIR/vagrant/Vagrantfile" $target
unset target
# Handle symlinks for Sublime Text 3
SUBLIME_USERDIR="$HOME/Library/Application Support/Sublime Text 3/Packages/User"
if [ $(uname) == "Darwin" ] && [ -d "$SUBLIME_USERDIR" ]; then
for file in $(find "$DOTFILES_DIR/sublime" -type f); do
# Get the filename from path
target=$(basename $file)
targetFile="$SUBLIME_USERDIR/$target"
if [ -f "$targetFile" ] && [ ! -L "$targetFile" ]; then
# Backup the existing file before linking.
mv "$targetFile" "$targetFile$date_suffix"
fi
# Makes the symlink to dotfile.
ln -sfv "$file" "$targetFile"
done
fi
unset target targetFile