-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup_mac
executable file
·96 lines (80 loc) · 2.27 KB
/
setup_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
#!/usr/bin/env bash
# exit when any command fails
set -e
function command_exists {
printf "Checking for $1 command... "
if command -v "$1" >/dev/null 2>&1; then
echo "Found"
return 0
else
echo "Not found"
return 1
fi
}
function dir_exists {
printf "Checking for $2 directory at $1... "
if [ -d $1 ]; then
echo "Found"
return 0
else
echo "Not found"
return 1
fi
}
function install_xcode_tools {
echo "Installing Xcode Tools"
xcode-select --install || echo "Already installed"
}
function install_homebrew {
echo "Installing Homebrew"
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
}
function install_homebrew_packages {
echo "Installing Hombrew packages using brew bundle"
brew bundle
}
function install_vundle {
printf "Installing Vundle..."
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
echo "Done"
}
function install_vundle_plugins {
printf "Installing Vundle plugins..."
vim +PluginInstall +qall
echo "Done"
}
function set_mac_prefs {
# Enable right-click
defaults write com.apple.driver.AppleBluetoothMultitouch.mouse MouseButtonMode TwoButton
# Enable full keyboard access for all controls (e.g. enable Tab in modal dialogs)
defaults write NSGlobalDomain AppleKeyboardUIMode -int 3
# Enable three-finger drag
defaults write com.apple.AppleMultitouchTrackpad TrackpadThreeFingerDrag -bool true
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad TrackpadThreeFingerDrag -bool true
}
function set_iterm_prefs {
# set iterm to load preferences from this folder
defaults write com.googlecode.iterm2 LoadPrefsFromCustomFolder -bool true
defaults write com.googlecode.iterm2 PrefsCustomFolder -string $(pwd)
}
function install_dotfile {
printf "Installing $1... "
if [[ -L ~/.$1 ]]; then
echo "Already installed"
return 0;
fi
touch ~/.$1
mv ~/.$1 ~/.$1_local
ln -s $(pwd)/$1 ~/.$1
echo "Done, existing ~/.$1 moved to ~/.$1_local"
}
install_xcode_tools
command_exists brew || install_homebrew
install_homebrew_packages
dir_exists ~/.vim/bundle/Vundle.vim vundle || install_vundle
install_vundle_plugins
set_mac_prefs
set_iterm_prefs
install_dotfile vimrc
install_dotfile zshrc
install_dotfile gitconfig