This repository was archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall
executable file
·110 lines (91 loc) · 2.87 KB
/
install
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
#!/bin/bash
# Inspired by https://github.com/necolas/dotfiles/blob/master/bin/dotfiles
DOTFILES_DIRECTORY="${HOME}/.dotfiles"
DOTFILES_TARBALL_PATH="https://github.com/kewah/dotfiles/tarball/master"
DOTFILES_GIT_REMOTE="[email protected]:kewah/dotfiles.git"
# If missing, download and extract the dotfiles repository
if [[ ! -d ${DOTFILES_DIRECTORY} ]]; then
printf "$(tput setaf 7)Downloading dotfiles...\033[m\n"
mkdir ${DOTFILES_DIRECTORY}
curl -fsSLo ${HOME}/dotfiles.tar.gz ${DOTFILES_TARBALL_PATH}
tar -zxf ${HOME}/dotfiles.tar.gz --strip-components 1 -C ${DOTFILES_DIRECTORY}
rm -rf ${HOME}/dotfiles.tar.gz
fi
source ${DOTFILES_DIRECTORY}/scripts/brew
source ${DOTFILES_DIRECTORY}/scripts/node
source ${DOTFILES_DIRECTORY}/scripts/gem
type_exists() {
if [ $(type -P $1) ]; then
return 0
fi
return 1
}
is_git_repo() {
$(git rev-parse --is-inside-work-tree &> /dev/null)
}
link() {
# Force create/replace the symlink.
ln -fs "${DOTFILES_DIRECTORY}/${1}" "${HOME}/${2}"
}
# Before relying on Homebrew, check that packages can be compiled
if ! type_exists "gcc"; then
echo "The XCode Command Line Tools must be installed first."
echo " Download them from: https://developer.apple.com/downloads"
exit 1
fi
# Check for Homebrew
if ! type_exists "brew"; then
echo "Installing Homebrew..."
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
fi
# Check for git
if ! type_exists "git"; then
echo "Updating Homebrew..."
brew update
echo "Installing Git..."
brew install git
fi
sudo chown -R $USER /usr/local
brew_run
node_run
npm_run
gem_run
# Initialize the git repository if it's missing
if ! is_git_repo; then
cd ${DOTFILES_DIRECTORY}
echo "Initializing git repository..."
git init
git remote add origin ${DOTFILES_GIT_REMOTE}
git fetch origin master
git reset --hard FETCH_HEAD
git clean -fd
git submodule init
git submodule update
fi
# Force remove the vim directory if it's already there.
if [ -e "${HOME}/.vim" ]; then
rm -rf "${HOME}/.vim"
fi
link "dotfiles/agignore" ".agignore"
link "dotfiles/aliases" ".aliases"
link "dotfiles/esformatter" ".esformatter"
link "dotfiles/eslintrc" ".eslintrc"
link "dotfiles/gitconfig" ".gitconfig"
link "dotfiles/gitignore" ".gitignore"
link "dotfiles/gitmessage" ".gitmessage"
link "dotfiles/gvimrc" ".gvimrc"
link "dotfiles/inputrc" ".inputrc"
link "dotfiles/npmrc" ".npmrc"
link "dotfiles/tmux" ".tmux.conf"
link "dotfiles/vimrc" ".vimrc"
link "dotfiles/zshenv" ".zshenv"
link "dotfiles/zshrc" ".zshrc"
link "vim" ".vim"
if [ -e "${HOME}/.zfunctions" ]; then
rm -rf "${HOME}/.zfunctions"
fi
mkdir "${HOME}/.zfunctions"
ln -fs "${DOTFILES_DIRECTORY}/zsh/themes/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" "${HOME}/.zfunctions/zsh-syntax-highlighting"
chsh -s /bin/zsh
source ${DOTFILES_DIRECTORY}/settings/osx
source ${DOTFILES_DIRECTORY}/settings/karabiner-import