Skip to content

Commit

Permalink
Merge pull request #98 from Okabe-Junya/Okabe-Junya/feat/install-script
Browse files Browse the repository at this point in the history
Feature: Add Install Script
  • Loading branch information
Okabe-Junya authored Aug 18, 2024
2 parents 4f2e7f4 + cb8f2ac commit e1bbf35
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 0 deletions.
69 changes: 69 additions & 0 deletions install.zsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/usr/bin/env zsh

function check_os() {
if [ "$(uname)" != "Darwin" ]; then
echo "This script is only for Mac OS X"
exit 1
else
sleep 1
echo "This OS is Mac OS X!"
fi
if [ "$(uname -m)" != "arm64" ]; then
echo "This Mac is Intel-based!"
echo "This script is only for Apple Silicon"
exit 1
else
sleep 1
echo "This Mac is Apple Silicon!"
fi
}

function install_command_line_tools() {
if [ ! -d "/Library/Developer/CommandLineTools" ]; then
echo "Installing Xcode Command Line Tools..."
xcode-select --install 2>/dev/null
else
sleep 1
echo "Xcode Command Line Tools is already installed!"
fi
}

function install_homebrew() {
if [ ! -d "/opt/homebrew" ]; then
echo "Installing Homebrew for Apple Silicon..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" 2>/dev/null
else
sleep 1
echo "Homebrew for Apple Silicon is already installed!"
fi
}

function initialize_symbolic_links() {
echo "Initializing symbolic links..."
source "${HOME}/dotfiles/install/symlink.zsh"
}

function brew_bundle_install() {
echo "Installing Homebrew Bundle..."
echo -n "Do you want to install Homebrew Bundle? [y/n]: "
read answer
case $answer in
[yY]*)
brew bundle install --file="${HOME}/dotfiles/install/Brewfile"
;;
*)
echo "Homebrew Bundle is not installed!"
;;
esac
}

function install() {
check_os
install_command_line_tools
install_homebrew
brew_bundle_install

echo "Installation is complete!"
}

install
File renamed without changes.
File renamed without changes.
8 changes: 8 additions & 0 deletions install/symlink.zsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env zsh

# config
ln -nfs "${HOME}/dotfiles/.config/git" "${HOME}/.config/git"
ln -nfs "${HOME}/dotfiles/.config/gh" "${HOME}/.config/gh"

# zshrc
ln -nfs "${HOME}/dotfiles/.zshrc" "${HOME}/.zshrc"

0 comments on commit e1bbf35

Please sign in to comment.