Last active
September 23, 2020 03:02
-
-
Save taingmeng/2c4d0207cbf9aa4598d7f3849118219f to your computer and use it in GitHub Desktop.
setup.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# A menu driven shell script sample template | |
## ---------------------------------- | |
# Step #1: Define variables | |
# ---------------------------------- | |
EDITOR=vim | |
PASSWD=/etc/passwd | |
RED='\033[0;41;30m' | |
STD='\033[0;0;39m' | |
# ---------------------------------- | |
# Step #2: User defined function | |
# ---------------------------------- | |
pause(){ | |
echo '' | |
read -p "Press [Enter] key to continue..." fackEnterKey | |
} | |
install_brew(){ | |
echo "Installing brew..." | |
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" | |
} | |
install_git(){ | |
echo "Installing git..." | |
brew install git | |
ssh-keygen -p -f ~/.ssh/id_rsa -N "" | |
pbcopy < ~/.ssh/id_rsa.pub | |
echo "SSH key copied to clipboard." | |
pause | |
} | |
# do something in two() | |
install_zshrc(){ | |
echo "Installing zshrc..." | |
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" | |
# Install font | |
git clone https://github.com/powerline/fonts.git --depth=1 | |
# install | |
cd fonts | |
./install.sh | |
# clean-up a bit | |
cd .. | |
rm -rf fonts | |
sed -i '' 's/ZSH_THEME=".*"/ZSH_THEME="agnoster"/g' ~/.zshrc | |
sed -i '' 's/plugins=(.*)/plugins=(git)/g' ~/.zshrc | |
source ~/.zshrc | |
echo ' Add the following settings to VSCode | |
"terminal.external.osxExec": "iTerm.app", | |
"terminal.integrated.fontFamily": "Meslo LG M DZ for Powerline", | |
"terminal.integrated.shell.osx": "/bin/zsh" | |
' | |
pause | |
} | |
install_jumpcut(){ | |
echo "Installing jumpcut..." | |
brew tap homebrew/cask | |
brew cask install jumpcut | |
} | |
install_nvm(){ | |
echo "Installing nvm..." | |
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash | |
nvm install --lts | |
nvm use node | |
} | |
install_pyenv(){ | |
echo "Installing pyenv with brew..." | |
brew install pyenv | |
pyenv install 3.7.0 | |
} | |
install_yarn(){ | |
echo "Installing yarn with brew..." | |
brew install yarn | |
} | |
install_pod(){ | |
echo "Installing cocoapod..." | |
sudo gem install cocoapods | |
} | |
install_watchman(){ | |
echo "Installing watchman..." | |
brew install watchman | |
} | |
install_autojump(){ | |
echo "Installing autojump..." | |
brew install autojump | |
} | |
export_adb(){ | |
echo "Export adb to zshrc..." | |
echo 'export ANDROID_HOME=/Users/$USER/Library/Android/sdk' >> ~/.zshrc | |
echo 'export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools' >> ~/.zshrc | |
source ~/.zshrc | |
pause | |
} | |
list_of_download_pages(){ | |
echo "Android Studio: https://developer.android.com/studio" | |
echo "Xcode: https://apps.apple.com/sg/app/xcode/id497799835?mt=12" | |
echo "VSCode: https://code.visualstudio.com/" | |
echo "Java: https://www.oracle.com/java/technologies/javase-downloads.html" | |
pause | |
} | |
# function to display menus | |
show_menus() { | |
clear | |
echo "~~~~~~~~~~~~~~~~~~~~~" | |
echo " M A I N - M E N U" | |
echo "~~~~~~~~~~~~~~~~~~~~~" | |
echo "0. Exit" | |
echo "1. Install brew" | |
echo "2. Install git" | |
echo "3. Install zsh" | |
echo "4. Install jumpcut" | |
echo "5. Install nvm" | |
echo "6. Install pyenv" | |
echo "7. Install yarn" | |
echo "8. Install pod" | |
echo "9. Install watchman" | |
echo "10. Install autojump" | |
echo "11. Export adb" | |
echo "d. List of download pages" | |
} | |
# read input from the keyboard and take a action | |
# invoke the one() when the user select 1 from the menu option. | |
# invoke the two() when the user select 2 from the menu option. | |
# Exit when user the user select 3 form the menu option. | |
read_options(){ | |
local choice | |
read -p "Enter choice: " choice | |
case $choice in | |
0) exit 0 ;; | |
1) install_brew ;; | |
2) install_git ;; | |
3) install_zshrc ;; | |
4) install_jumpcut ;; | |
5) install_nvm ;; | |
6) install_pyenv ;; | |
7) install_yarn ;; | |
8) install_pod ;; | |
9) install_watchman ;; | |
10) install_autojump ;; | |
11) export_adb ;; | |
d) list_of_download_pages ;; | |
*) echo -e "${RED}Error...${STD}" && sleep 2 | |
esac | |
} | |
# ---------------------------------------------- | |
# Step #3: Trap CTRL+C, CTRL+Z and quit singles | |
# ---------------------------------------------- | |
# trap '' SIGINT SIGQUIT SIGTSTP | |
# ----------------------------------- | |
# Step #4: Main logic - infinite loop | |
# ------------------------------------ | |
while true | |
do | |
show_menus | |
read_options | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment