-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbootstrap.sh
More file actions
executable file
·117 lines (102 loc) · 3 KB
/
bootstrap.sh
File metadata and controls
executable file
·117 lines (102 loc) · 3 KB
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
#!/usr/bin/env bash
# Purpose: Install all dotfiles on clean system
# Usage: `source boostrap.sh`
if [[ -f ~/.bashrc ]]; then
set -x
mv ~/.bashrc ~/.bashrc.bk
{ set +x; } &>/dev/null
fi
if [[ -f ~/.bash_profile ]]; then
set -x
mv ~/.bash_profile ~/.bash_profile.bk
{ set +x; } &>/dev/null
fi
echo
echo "#########################"
echo "# Updating machine name #"
echo "#########################"
sed -i' ' "s/^\(# Configuration:\) MACHINE_NAME.*/\1 ${HOSTNAME}/" bash/.bashrc
if [[ ! -f ~/.machine ]]; then
echo "# [${HOSTNAME}] Machine-Specific Configs" > ~/.machine
fi
# Platform-specific setup
case $OSTYPE in
linux*|msys*)
if [[ "/home/$USER/dotfiles" != $PWD ]]; then
echo "Must be run from expected dir: ~/dotfiles" >&2
return 1
fi
source linux_bootstrap.sh
;;
darwin*)
if [[ "/Users/${USER}/dotfiles" != $PWD ]]; then
echo "Must be run from expected dir: ~/dotfiles" >&2
return 1
fi
source mac_bootstrap.sh
;;
esac
echo
echo "####################"
echo "# Stowing Dotfiles #"
echo "####################"
for pkg in $(ls .); do
if [[ -d $pkg ]]; then
set -x
stow $pkg
ret=$?
{ set +x; } &>/dev/null
fi
done
echo
echo "###############"
echo "# Emacs setup #"
echo "###############"
set -x
emacs --batch --script ~/.emacs.d/init.el &> emacs-compile.$(date "+%Y_%m_%d__%H_%M_%S")
source ~/.bashrc
{ set +x; } &>/dev/null
emacs_version=$(emacs --version | head -n 1)
echo "Emacs Version: [${emacs_version}]"
echo
echo "###################################################"
echo "# Check .git-completion file against upstream tip #
echo "###################################################"
if [[ $(wget -q --spider http://github.com) -eq 0 ]]; then
wget https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash
if [[ $(diff -q git-completion.bash git/.git-completion 1>/dev/null) -ne 0 ]]; then
echo "Warning: .git-completion needs updating. Updating it now..." >&2
mv -f git-completion.bash git/.git-completion
fi
wget https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh
if [[ $(diff -q git-prompt.sh git/.git-prompt 1>/dev/null) -ne 0 ]]; then
echo "Warning: .git-prompt needs updating. Updating it now..." >&2
mv -f git-prompt.sh git/.git-prompt
fi
else
echo "Skipping check, no network connection to github.com." >&2
fi
echo
echo "##############"
echo "# Git Config #"
echo "##############"
read -p "Git Email Address: " _email
git config --global user.email "${_email}"
echo
echo "##############"
echo "# SSH Keygen #"
echo "##############"
echo -en "Is this the right identity for ssh [${_email}]? "
read -p "[y/n]: " -n 1 -r
if [[ $REPLY =~ ^[Yy]$ ]]; then
set -x
ssh-keygen -t ed25519 -C "${_email}"
{ set +x; } &>/dev/null
if [[ $OSTYPE =~ "darwin" ]]; then
set -x
ssh-add --apple-use-keychain ~/.ssh/id_ed25519
{ set +x; } &>/dev/null
fi
fi
echo
echo "dotfiles installation done."