-
Notifications
You must be signed in to change notification settings - Fork 1
/
dotfiles.sh
executable file
·123 lines (117 loc) · 3.27 KB
/
dotfiles.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#!/bin/bash
set -e
automated_update_msg () {
echo "AUTOMATED DOTFILES UPDATE | $(whoami)@$(hostname)"
}
sync_submodules () {
VIMDIR=".vim/bundle"
SUBMODULES="${VIMDIR}/vim-fugitive ${VIMDIR}/vim-go"
for submodule in ${SUBMODULES}; do
echo "Updating ${submodule}..."
cd ${submodule} >/dev/null
git add --all :/ >/dev/null && git commit -m "$(automated_update_msg)"
cd - >/dev/null
done
}
provision_ubuntu () {
#echo 127.0.1.1 $(hostname) | sudo tee -a /etc/hosts
sudo apt-get update
sudo apt-get install -y python2 libpython2-dev python3 libpython3-dev python3-venv tree git mercurial jq tmux htop make build-essential autojump vim curl strace sysstat tcpdump dnsutils zip unzip
curl -sL https://deb.nodesource.com/setup_18.x | sudo bash -
sudo apt-get install -y nodejs
sudo npm install -g prettier
curl https://raw.githubusercontent.com/git/git/fd99e2bda0ca6a361ef03c04d6d7fdc7a9c40b78/contrib/diff-highlight/diff-highlight | sudo tee /usr/local/bin/diff-highlight && sudo chmod +x /usr/local/bin/diff-highlight
VERSION="1.19.5"
OS="linux"
UNAME_ARCH=$(uname -m)
if [[ "${UNAME_ARCH}" == "x86_64" ]]; then
ARCH="amd64"
else
ARCH="arm64"
fi
sudo wget https://storage.googleapis.com/golang/go${VERSION}.${OS}-${ARCH}.tar.gz -O /usr/local/go.tar.gz
sudo tar -C /usr/local -xzf /usr/local/go.tar.gz
sudo rm /usr/local/go.tar.gz
}
provision_osx () {
brew install \
bash \
wget \
jq \
cmake \
tmux \
weechat \
mercurial \
gnutls \
node \
tree \
autojump \
openssl \
coreutils \
findutils \
gnu-tar \
gnu-sed \
gawk \
gnutls \
gnu-indent \
gnu-getopt \
bash-completion@2
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
}
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
case "$1" in
diff)
cd ${DIR} >/dev/null
git diff
cd - >/dev/null
;;
install)
FILES_TO_LINK=".vim .vimrc .bashrc .oh-my-zsh"
for file in ${FILES_TO_LINK}; do
rm -rf ${HOME}/${file}
done
cd ${DIR} >/dev/null
git submodule update --init --recursive
(
cd .vim/bundle/ctrlp-matcher && ./install.sh && cd -
)
cd - >/dev/null
for file in ${FILES_TO_LINK}; do
ln -s ${DIR}/${file} ${HOME}/${file}
done
;;
provision)
case "$2" in
ubuntu)
provision_ubuntu
;;
osx)
provision_osx
;;
*)
echo "Unknown OS specified. Usage: dotfiles provision [ubuntu|osx]"
exit 1
esac
if [[ ! -e ~/.ssh/id_rsa ]]; then
ssh-keygen -t rsa -N "" -f ~/.ssh/id_rsa
fi
;;
sync)
cd ${DIR} >/dev/null
git fetch origin
if [[ "$2" == "" ]]; then
MSG=$(automated_update_msg)
else
MSG=$2
fi
#sync_submodules
git add --all :/ && \
git commit -m "${MSG}"
git rebase origin/master
git push origin master
cd - >/dev/null
;;
*)
echo "Usage: dotfiles [diff|install|sync]"
exit 1
esac