-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·77 lines (67 loc) · 1.95 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/bin/bash
#
# hdevieux
# this is used to create and manage dotfiles symlinks from home directory
# to dotfiles repository
OS="$(uname -s)"
DOTFILES_DIR="$HOME"/dotfiles
BACKUP_DIR="$HOME"/.dotfiles_backup
MANAGED_FILES="bashrc\
bash_functions\
bash_profile\
bash_aliases\
emacs.d\
inputrc\
tmux.conf\
tmux\
vimrc\
vim"
function GIT_CMD() {
git --git-dir="$DOTFILES_DIR"/.git --work-tree="$DOTFILES_DIR" "$@"
}
# verify things are ready
if [ ! -d "$DOTFILES_DIR" ]; then
echo "$DOTFILES_DIR not found. Exiting"
exit 1
fi
GIT_CMD diff-index --quiet HEAD -- \
&& GIT_CMD pull \
|| echo "WARNING: Unstaged changes to dotfiles repo."
if [ -d "$BACKUP_DIR" ]; then
printf "Overwriting backup dir... "
rm -rf "$BACKUP_DIR"
echo "DONE"
fi
mkdir -p "$BACKUP_DIR"
# install links to managed dotfiles, backing up any existing
# ones that might already be installed
for f in $MANAGED_FILES
do
if [ "$(dirname "$(readlink "$HOME"/."$f")")" == "$DOTFILES_DIR" ]; then
echo "$f already linked"
else
if [ -e "$HOME"/."$f" ]; then
echo "Backing up $f"
mv "$HOME"/."$f" "$BACKUP_DIR/"
fi
echo "Installing symlink to $f"
ln -s "$DOTFILES_DIR"/"$f" "$HOME"/."$f"
fi
done
# Tmux directory for resurrection backups
if [ ! -d "$HOME"/.tmux_resurrection ]; then
mkdir "$HOME"/.tmux_resurrection
fi
# Configure iTerm2 if on a mac
if [ "$OS" == "Darwin" ]; then
if [ "$(dirname "$(readlink "$HOME"/.iterm)")" == "$DOTFILES_DIR" ]; then
echo ".iterm already linked"
else
if [ -e "$HOME"/.iterm ]; then
echo "Backing up .iterm"
mv "$HOME"/.iterm "$BACKUP_DIR/"
fi
ln -s "$DOTFILES_DIR"/iterm "$HOME"/.iterm
echo "$HOME/.iterm installed. Be sure to configure iTerm2 settings dir"
fi
fi