-
Notifications
You must be signed in to change notification settings - Fork 1
/
clone-dotfiles
executable file
·39 lines (34 loc) · 1.07 KB
/
clone-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
#!/bin/bash
set -e -u -f -o pipefail
# Initial setup won't have the right environment, so extend $PATH.
PATH="${HOME}/bin:/opt/homebrew/bin:/usr/local/bin:${PATH}"
export PATH
# Stop git looking for a commit message when 'git pull' is run.
GIT_MERGE_AUTOEDIT=no
export GIT_MERGE_AUTOEDIT
if [[ -z "$(type -a vim)" ]]; then
echo "Missing vim :(" >&2
echo "apt-get install vim-nox" >&2
exit 1
fi
DESTDIR="${HOME}/src/dotfiles"
readonly DESTDIR
if [[ ! -d "${DESTDIR}" ]]; then
mkdir -p "$(dirname "${DESTDIR}")"
git clone https://github.com/tobinjt/dotfiles.git "${DESTDIR}"
fi
cd "${DESTDIR}"
# Make .ssh inaccessible.
chmod 700 .ssh
git pull --no-rebase
git submodule init
git submodule update
# Remove .bashrc that linkdirs will not overwrite.
rm -f "${HOME}/.bashrc"
dotfiles
if [[ "${USER}" == "johntobin" ]]; then
sed -i -e 's!https://github.com/[email protected]:!' .git/config
# I need to do this anyway, so might as well do it now.
sed -i -e 's!https://github.com/[email protected]:!' "${HOME}/bin/.git/config"
(cd "${HOME}/bin" && pre-commit install --install-hooks)
fi