Repository navigation
Expand file tree
/
Copy pathprovision.sh
More file actions
executable file
·137 lines (93 loc) · 3.06 KB
/
Copy pathprovision.sh
File metadata and controls
executable file
·137 lines (93 loc) · 3.06 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# this script rapidly sets up my Macintosh computer the way I like it!
# ------------------------ DEMONSTRATION CASES ----------------------------
function installCowsay() {
echo "Installing cowsay..."
(brew install cowsay)
}
function uninstallCowsay() {
echo "Uninstalling cowsay..."
(brew uninstall cowsay)
}
function executeCowsay() {
(cowsay moo)
}
# -------------------------------------------------------------------------
# -------------------------- HELPER FUNCTIONS -----------------------------
function PutSymlink() {
if [[ -d "$1" || -f "$1" ]]; then
read "REPLY?A directory already exists for $2, do you want to overwrite it?"
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
rm $1 && ln -s -f $3 $4
fi
fi
}
# -------------------------------------------------------------------------
function start() {
# - PRECONFIGs -
# Show hidden files
echo "Setting hidden files to show..."
(defaults write com.apple.Finder AppleShowAllFiles true && killall Finder)
# - HOMEBREW INSTALLATION -
echo "Installing homebrew..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Install applications specified in the brewfile
echo "Installing brewfile specifications..."
(cp ~/Dropbox/Apps/Homebrew/Brewfile . && brew bundle)
echo "Testing cowsay..."
installCowsay
executeCowsay
uninstallCowsay
# Import sublime settings
echo "Provisioning sublime settings..."
(cd ~/Library/Application\ Support/Sublime\ Text/Packages/ && rm -r User && ln -s ~/Dropbox/Apps/Sublime/User)
# Installing OhMyZsh
echo "Installing Ohmyzsh..."
(sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)")
echo "Installing zsh plugins"
# The ZSH Autosuggestions Plugin
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
# Symlinking dotfiles
echo "Symlinking dotfiles..."
echo "[1] /.ssh"
DIR="$HOME/.ssh"
PutSymlink $DIR "ssh keys" ~/Dropbox/Apps/dot/ssh ~/.ssh
echo "[2] .zshrc"
DIR="$HOME/.zshrc"
PutSymlink $DIR "zshrc" ~/Dropbox/Apps/dot/zshrc ~/.zshrc
echo "[3] .zsh_history"
DIR="$HOME/.zsh_history"
PutSymlink $DIR "zsh_history" ~/Dropbox/Apps/dot/zsh_history ~/.zsh_history
}
function backup() {
DIRS_TO_BACKUP=("FileZilla"
"Homebrew"
"dot"
"Sublime"
"iTerm"
"Alfred")
BACKUP_DIRPATHS=( "${DIRS_TO_BACKUP[@]/#/$HOME/Dropbox/Apps/}" )
BACKUP_TARGET_DIR="$HOME/Dropbox/backups/"
BACKUP_NAME=$USER-backup-$(date +%Y%m%d)
echo "Creating backup snapshot of configurations..."
mkdir -p $DROPBOX_TARGET_DIR
if [ -d "~/Dropbox/Apps" ]; then
BACKUP=$BACKUP_NAME.tgz
# sudo?
tar -PkcZf $DROPBOX_TARGET_DIR$BACKUP $BACKUP_DIRPATHS > /dev/null
mv $BACKUP $BACKUP_TARGET_DIR
echo "Backup complete."
else
echo "Error: Hmm, you don't have any folders to backup."
fi
}
function push() {
# Backup before pushing new preferences
backup
echo "Creating the Brewfile..."
# (brew tap Homebrew/bundle && brew bundle dump)
echo "Moving to dropbox..."
# (mv -f Brewfile $HOME/Dropbox/Apps/Homebrew/)
}
"$@"