Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 181 lines (152 sloc) 6.07 KB
#!/bin/zsh
set -euxo
# force flag
FORCE_FLAG=''
print_usage() {
printf "Usage: Only -f(=force) option is allowed"
}
while getopts 'f' flag; do
case "${flag}" in
f) FORCE_FLAG='true' ;;
*) print_usage
exit 1 ;;
esac
done
MACOS=$( cd "$( dirname "$0" )" >/dev/null 2>&1 && pwd )
DOTFILES=$( dirname "${MACOS}" )
# System Prefernce
source "${MACOS}/.macos"
# install softwares
brew update
brew bundle --file="${MACOS}/Brewfile"
brew cask upgrade
export PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH"
# shell
if [ ! -z ${FORCE_FLAG} ];then
sudo ln -f ${MACOS}/shell/shells /etc/shells
chsh -s /bin/zsh
fi
yes | cp -afl "${MACOS}/shell/common/".* "${HOME}/"
yes | cp -afl "${MACOS}/shell/bash/".* "${HOME}/"
# fish
if [ ! -z ${FORCE_FLAG} ] || [ ! -f ~/.config/fish/functions/fisher.fish ];then
curl -Lo ~/.config/fish/functions/fisher.fish --create-dirs git.io/fisher
fi
yes | cp -afl "${MACOS}/shell/fish/config/". "${HOME}/.config/fish/"
fish -c fisher
# zsh
ZDOTDIR="${HOME}/.zsh"
mkdir -p "${ZDOTDIR}"
ZDOTPREZTO="${ZDOTDIR}/.zprezto"
if [ -d "${ZDOTPREZTO}" ];then
if [ ! -z ${FORCE_FLAG} ];then
$(cd ${ZDOTPREZTO} && git pull && git submodule update --init --recursive)
fi
else
git clone --recursive https://github.com/sorin-ionescu/prezto.git "${ZDOTPREZTO}"
fi
HIROGA_PROMPT="${ZDOTPREZTO}/modules/prompt/functions/prompt_hiroga_setup"
test -f "${HIROGA_PROMPT}" || ln -f "${MACOS}/shell/zsh/prompt_hiroga_setup" "${HIROGA_PROMPT}"
ZSH_COMPLETION="/usr/local/share/zsh-completions"
mkdir -p ${ZSH_COMPLETION}
if [ -d "${ZSH_COMPLETION}" ];then
if [ ! -z ${FORCE_FLAG} ] || [ ! -f "${ZSH_COMPLETION}/_hub" ];then
curl https://raw.githubusercontent.com/github/hub/master/etc/hub.zsh_completion -o "${MACOS}/shell/zsh/completion/_hub"
ln -fns "${MACOS}/shell/zsh/completion/_hub" "${ZSH_COMPLETION}/_hub"
fi
fi
yes | cp -afl "${MACOS}/shell/zsh/.zsh/".* "${ZDOTDIR}/"
ln -fns "${MACOS}/shell/zsh/.zshenv" "${HOME}/.zshenv"
# env
yes | anyenv install --init || :
anyenv install pyenv -s
anyenv install nodenv -s
anyenv install rbenv -s
eval "$(anyenv init -)"
# node
NODE12=12.16.0
nodenv install ${NODE12} -s
nodenv global ${NODE12}
# python
PYTHON_3_7=3.7.4
PYTOHN3_8=3.8.1
pyenv install ${PYTHON_3_7} -s
pyenv install ${PYTOHN3_8} -s
pyenv global ${PYTHON_3_7}
# ruby
RUBY_VERSION=2.6.4
rbenv install ${RUBY_VERSION} -s
rbenv global ${RUBY_VERSION}
bundler -h >/dev/null 2>&1 || sudo gem install bundler
gem specific_install >/dev/null 2>&1 || sudo gem install specific_install
t -h >/dev/null 2>&1 || sudo gem specific_install http://github.com/hiroga-cc/t.git
# aws
AWS_ALIAS_DIR="$HOME/.aws/cli/alias"
if [ ! -z ${FORCE_FLAG} ] || [ ! -f ${AWS_ALIAS_DIR} ];then
awscli_aliases_temp_dir=$(mktemp -d)
git clone https://github.com/awslabs/awscli-aliases.git ${awscli_aliases_temp_dir}
mkdir -p ~/.aws/cli
cp -f ${awscli_aliases_temp_dir}/alias ${AWS_ALIAS_DIR}/alias
fi
# docker
ln -fns /Applications/Docker.app/Contents/Resources/etc/docker.bash-completion /usr/local/etc/bash_completion.d/docker
ln -fns /Applications/Docker.app/Contents/Resources/etc/docker-compose.bash-completion /usr/local/etc/bash_completion.d/docker-compose
ln -fns /Applications/Docker.app/Contents/Resources/etc/docker-machine.bash-completion /usr/local/etc/bash_completion.d/docker-machine
ln -fns /Applications/Docker.app/Contents/Resources/etc/docker.zsh-completion "${ZSH_COMPLETION}/_docker"
ln -fns /Applications/Docker.app/Contents/Resources/etc/docker-compose.zsh-completion "${ZSH_COMPLETION}/_docker-compose"
ln -fns /Applications/Docker.app/Contents/Resources/etc/docker-machine.zsh-completion "${ZSH_COMPLETION}/_docker-machine"
# gcloud
gcloud components update --quiet
gcloud components install beta --quiet
# git
yes | cp -afl "${DOTFILES}/bin/git/".* "${HOME}/"
GIT_PROMPT_SH="$HOME/.git-prompt.sh"
if [ ! -z ${FORCE_FLAG} ] || [ ! -f ${GIT_PROMPT_SH} ];then
curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh -o ${GIT_PROMPT_SH}
fi
GIT_COMPLETION_BASH="${HOME}/.git-completion.bash"
if [ ! -z ${FORCE_FLAG} ] || [ ! -f ${GIT_COMPLETION_BASH} ];then
curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash -o ${GIT_COMPLETION_BASH}
fi
# go
export GOPATH=~/.go
mkdir -p "${GOPATH}"
# haskell
command -v ghcup 1>/dev/null 2>&1 || curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh
# nvm
export NVM_DIR="$HOME/.nvm"
if [ ! -z ${FORCE_FLAG} ] || [ ! -d ${NVM_DIR} ];then
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.0/install.sh | bash
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
NODE_LATEST=12
nvm install 8 --lts
nvm install ${NODE_LATEST}
fi
# node
bash-language-server -h >/dev/null 2>&1 || npm install -g bash-language-server
base64url >/dev/null 2>&1 || npm install -g base64-url-cli
json-server -h >/dev/null 2>&1 || npm install -g json-server
redoc-cli --help >/dev/null 2>&1 || npm install -g redoc-cli
tsc -h >/dev/null 2>&1 || npm install -g typescript
# OneDrive
ONEDRIVE_SYNC_DIR=$HOME/OneDrive\ -\ $(whoami)
mkdir -p "${ONEDRIVE_SYNC_DIR}/Images/Screenshots/$(uname -n)"
defaults write com.apple.screencapture location "${ONEDRIVE_SYNC_DIR}/Images/Screenshots/$(uname -n)"
if [ ! -z ${FORCE_FLAG} ] || [ ! -s "$HOME/.sdkman/bin/sdkman-init.sh" ];then
curl -s "https://get.sdkman.io" | bash
export SDKMAN_DIR="$HOME/.sdkman"
source "$HOME/.sdkman/bin/sdkman-init.sh"
sdk install java 8.0.222.j9-adpt
sdk install java 12.0.1.j9-adpt
fi
# tmux
ln -f "${DOTFILES}/bin/tmux/.tmux.conf" $HOME/.tmux.conf
# vim
ln -f "${DOTFILES}/bin/vim/.vimrc" $HOME/.vimrc
# VSCode
VSCODE_USER_SETTING=$HOME/Library/Application\ Support/Code/User
yes | cp -afl "${DOTFILES}/bin/vscode/User/". "${VSCODE_USER_SETTING}/"
cp -f "${DOTFILES}/bin/vscode/code" "/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code"
source "${DOTFILES}/bin/vscode/setup"
print -P "%F{green}SUCCESS\!\!\!"
You can’t perform that action at this time.