forked from thomastardy/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·158 lines (127 loc) · 4.53 KB
/
install.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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#!/usr/bin/env bash
###########################
# This script installs the dotfiles and runs all other system configuration scripts
# @author Adam Eivy
###########################
DEFAULT_EMAIL="[email protected]"
DEFAULT_GITHUBUSER="atomantic"
DEFAULT_NAME="Adam Eivy"
DEFAULT_USERNAME="antic"
# include my library helpers for colorized echo and require_brew, etc
source ./lib.sh
# make a backup directory for overwritten dotfiles
mkdir -p ~/.dotfiles_backup
# ensure ~/.gitshots exists
mkdir -p ~/.gitshots
bot "Hi. I'm going to make your OSX system better. But first, I need to configure this project based on your info so you don't check in files to github as Adam Eivy from here on out :)"
fullname=`osascript -e "long user name of (system info)"`
if [[ -n "$fullname" ]];then
lastname=$(echo $fullname | awk '{print $2}');
firstname=$(echo $fullname | awk '{print $1}');
fi
# me=`dscl . -read /Users/$(whoami)`
if [[ -z $lastname ]]; then
lastname=`dscl . -read /Users/$(whoami) | grep LastName | sed "s/LastName: //"`
fi
if [[ -z $firstname ]]; then
firstname=`dscl . -read /Users/$(whoami) | grep FirstName | sed "s/FirstName: //"`
fi
email=`dscl . -read /Users/$(whoami) | grep EMailAddress | sed "s/EMailAddress: //"`
if [[ ! "$firstname" ]];then
response='n'
else
echo -e "I see that your full name is $COL_YELLOW$firstname $lastname$COL_RESET"
read -r -p "Is this correct? [Y|n] " response
fi
if [[ $response =~ ^(no|n|N) ]];then
read -r -p "What is your first name? " firstname
read -r -p "What is your last name? " lastname
fi
fullname="$firstname $lastname"
bot "Great $fullname, "
if [[ ! $email ]];then
response='n'
else
echo -e "The best I can make out, your email address is $COL_YELLOW$email$COL_RESET"
read -r -p "Is this correct? [Y|n] " response
fi
if [[ $response =~ ^(no|n|N) ]];then
read -r -p "What is your email? [$DEFAULT_EMAIL] " email
if [[ ! $email ]];then
email=$DEFAULT_EMAIL
fi
fi
grep 'user = atomantic' .gitconfig
if [[ $? = 0 ]]; then
read -r -p "What is your github.com username? [$DEFAULT_GITHUBUSER]" githubuser
fi
if [[ ! $githubuser ]];then
githubuser=$DEFAULT_GITHUBUSER
fi
running "replacing items in .gitconfig with your info ($COL_YELLOW$fullname, $email, $githubuser$COL_RESET)"
# test if gnu-sed or osx sed
sed -i "s/$DEFAULT_NAME/$firstname $lastname/" .gitconfig > /dev/null 2>&1 | true
if [[ ${PIPESTATUS[0]} != 0 ]]; then
echo
running "looks like you are using OSX sed rather than gnu-sed, accommodating"
sed -i '' "s/$DEFAULT_NAME/$firstname $lastname/" .gitconfig;
sed -i '' 's/'$DEFAULT_EMAIL'/'$email'/' .gitconfig;
sed -i '' 's/'$DEFAULT_GITHUBUSER'/'$githubuser'/' .gitconfig;
sed -i '' 's/'$DEFAULT_USERNAME'/'$(whoami)'/g' .zshrc;ok
else
echo
bot "looks like you are already using gnu-sed. woot!"
sed -i 's/'$DEFAULT_EMAIL'/'$email'/' .gitconfig;
sed -i 's/'$DEFAULT_GITHUBUSER'/'$githubuser'/' .gitconfig;
sed -i 's/'$DEFAULT_USERNAME'/'$(whoami)'/g' .zshrc;ok
fi
# read -r -p "OK? [Y/n] " response
# if [[ ! $response =~ ^(yes|y|Y| ) ]];then
# exit 1
# fi
# bot "awesome. let's roll..."
echo $0 | grep zsh > /dev/null 2>&1 | true
if [[ ${PIPESTATUS[0]} != 0 ]]; then
running "changing your login shell to zsh"
chsh -s $(which zsh);ok
else
bot "looks like you are already using zsh. woot!"
fi
git clone https://github.com/bhilburn/powerlevel9k.git oh-my-zsh/custom/themes/powerlevel9k
read -r -p "Do you want to use the project desktop background? [Y|n] " response
if [[ $response =~ ^(no|n|N) ]];then
echo "skipping...";
ok
else
running "Set a custom wallpaper image"
# `DefaultDesktop.jpg` is already a symlink, and
# all wallpapers are in `/Library/Desktop Pictures/`. The default is `Wave.jpg`.
rm -rf ~/Library/Application Support/Dock/desktoppicture.db
sudo rm -f /System/Library/CoreServices/DefaultDesktop.jpg
sudo rm -f /Library/Desktop\ Pictures/El\ Capitan.jpg
sudo cp ./img/wallpaper.jpg /System/Library/CoreServices/DefaultDesktop.jpg;
sudo cp ./img/wallpaper.jpg /Library/Desktop\ Pictures/El\ Capitan.jpg;ok
fi
pushd ~ > /dev/null 2>&1
bot "creating symlinks for project dotfiles..."
symlinkifne .crontab
symlinkifne .config/fontconfig
symlinkifne .gemrc
symlinkifne .gitconfig
symlinkifne .gitignore
symlinkifne .profile
symlinkifne .screenrc
symlinkifne .shellaliases
symlinkifne .shellfn
symlinkifne .shellpaths
symlinkifne .shellvars
symlinkifne .tmux.conf
symlinkifne .vim
symlinkifne .vimrc
symlinkifne .zlogout
symlinkifne .zprofile
symlinkifne .zshenv
symlinkifne .zshrc
popd > /dev/null 2>&1
./osx.sh
bot "Woot! All done."