forked from thoughtbot/laptop
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmac
109 lines (89 loc) · 1.99 KB
/
mac
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
#!/bin/sh
# Error handling
trap 'ret=$?; test $ret -ne 0 && printf "failed\n\n" >&2; exit $ret' EXIT
set -e
# Utility methods
append_to_zshrc() {
local text="$1" zshrc
local skip_new_line="${2:-0}"
if [ -w "$HOME/.zshrc.local" ]; then
zshrc="$HOME/.zshrc.local"
else
zshrc="$HOME/.zshrc"
fi
if ! grep -Fqs "$text" "$zshrc"; then
if [ "$skip_new_line" -eq 1 ]; then
printf "%s\n" "$text" >> "$zshrc"
else
printf "\n%s\n" "$text" >> "$zshrc"
fi
fi
}
app_is_installed() {
local app_name
app_name=$(echo "$1" | cut -d'-' -f1)
find /Applications -iname "$app_name*" -maxdepth 1 | egrep '.*' > /dev/null
}
fancy_echo() {
local fmt="$1"; shift
printf "\n$fmt\n" "$@"
}
git_clone_or_pull() {
local REPOSRC=$1
local LOCALREPO=$2
local LOCALREPO_VC_DIR=$LOCALREPO/.git
if [ ! -d $LOCALREPO_VC_DIR ]; then
git clone --recursive $REPOSRC $LOCALREPO
else
pushd $LOCALREPO
git pull $REPOSRC && git submodule update --init --recursive
popd
fi
}
# Welcome
echo
echo "Welcome to the Accedian NPAV OSX laptop script"
echo "----------------------------------------------"
echo
# Usage
usage() {
echo "Usage: $0 [-e <test>]" 1>&2
exit 1
}
# Handle some options
while getopts ":e:" opt; do
case $opt in
e)
environment=${OPTARG}
if [ "$environment" != "test" ]; then
usage
fi
;;
*)
usage
;;
esac
done
# Common setup
if [ ! -d "$HOME/.bin/" ]; then
mkdir "$HOME/.bin"
fi
# Source the child scripts
[ $environment ] && prefix="lib/" || prefix="./"
source "${prefix}xcode"
source "${prefix}homebrew"
source "${prefix}zsh"
source "${prefix}shell"
source "${prefix}terminal"
source "${prefix}unix"
source "${prefix}git"
source "${prefix}ssh"
source "${prefix}ide"
source "${prefix}server"
source "${prefix}web"
source "${prefix}tools"
# Run local customizations
if [ -f "$HOME/.laptop.local" ]; then
fancy_echo "Running your customizations from ~/.laptop.local ..."
. "$HOME/.laptop.local"
fi