-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall-dotfiles
executable file
·88 lines (72 loc) · 2.3 KB
/
install-dotfiles
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
78
79
80
81
82
83
84
85
86
87
88
# Run this to install and update all the dotfiles in $HOME/dotfiles
# Set function via http://stackoverflow.com/a/8574392/135978
# Also works in bash 3.2 so you can install on a Mac
# Duplicated here so the installation file can be run stand-alone
containsElement() {
set +x
local e
for e in "${@:2}"; do [[ "$e" == "$1" ]] && set -x && return 0; done
set -x
return 1
}
set -x
export CONFIGDIR="${CONFIGDIR:-$HOME/dotfiles}";
LOCAL_BIN=${LOCAL_BIN:-~/.local/bin}
if [ ! -d $CONFIGDIR ]; then
git clone https://github.com/svieira/dotfiles $CONFIGDIR
else
pushd $CONFIGDIR
git pull origin master
popd
fi
while : ; do
command -v brew >/dev/null 2>&1 && break || {
echo >&2 "brew is not currently installed, please install it"
read -p "Continue? [Y/n]" answer
[[ "$answer" =~ "[nNqQ]" ]] && exit 1;
}
done
# Install brew-managed programs
brew bundle install --file $CONFIGDIR/Brewfile
_brew_prefix="$(brew --prefix)"
for f in bashrc profile inputrc vimrc psqlrc
do
[ -f ~/.$f -a ! -L ~/.$f ] && mv ~/.$f ~/.$f.old
[ -L ~/.$f ] && continue
ln -s $CONFIGDIR/$f ~/.$f
done
# Local machine setup
# Ensure that we're using latest bash as our login shell
if grep -i $_brew_prefix/bin/bash /etc/shells > /dev/null; then
echo "Homebrew-managed bash already in /etc/shells"
else
echo "$_brew_prefix/bin/bash" | sudo tee -a /etc/shells > /dev/null
chsh -s $_brew_prefix/bin/bash
fi
if (( BASH_VERSINFO < 4 )); then
echo "Descending into subshell using homebrewed bash"
$_brew_prefix/bin/bash -l "$0"
fi
. ~/.profile
mkdir -p $HOME/.local
mkdir -p $LOCAL_BIN
mkdir -p $HOME/.local/opt
mkdir -p $HOME/.local/opt/cdpath
# For vim files: see vimrc
mkdir -p $HOME/.vim/backups
mkdir -p $HOME/.vim/swaps
mkdir -p $HOME/.vim/undo
# Link all bin files
for program in $CONFIGDIR/bin/*; do
program=${program##*/}
[[ -f $LOCAL_BIN/$program ]] && continue
ln -s $CONFIGDIR/bin/$program $LOCAL_BIN/$program
done
# Improve Mac Dictionary
# Still need to update Dictionary.app preferences manually
# Go to Preferences of Dictionary.app, select Webster's Unabridged Dictionary and drag it to the top.
git clone https://github.com/altosaar/webster-mac.git
cp -r webster-mac/Webster\'s\ Unabridged\ Dictionary.dictionary /Users/`whoami`/Library/Dictionaries/
rm -rf webster-mac
set +x
echo "Installation complete"