Skip to content

Instantly share code, notes, and snippets.

@pozgo
Last active January 20, 2017 13:34
Show Gist options
  • Save pozgo/4bd5e1357cffa24833130da6b287cd1d to your computer and use it in GitHub Desktop.
Save pozgo/4bd5e1357cffa24833130da6b287cd1d to your computer and use it in GitHub Desktop.
zsh-install
#!/usr/bin/env bash
# Supports only Linux(RedHat/Centos/Fedora) and OSX
# Bash Colors
red=`tput setaf 1`
green=`tput setaf 2`
yellow=`tput setaf 3`
white=`tput setaf 7`
bold=`tput bold`
reset=`tput sgr0`
separator=$(echo && printf '=%.0s' {1..100} && echo)
# Logging Finctions
log() {
if [[ "$@" ]]; then echo "${bold}${green}[LOG `date +'%T'`]${reset} $@";
else echo; fi
}
install_packages() {
log "Installing packages if missing"
if [ $(uname) == "Linux" ]; then
yum install -y zsh git which fontconfig bc
yum clean all
elif [ $(uname) == "Darwin" ]; then
BREW_BIN=`which brew`
if [[ ${BREW_BIN} == "" ]]; then
log "Mac Brew not installed. Please install Brew!"
log "Visit: http://brew.sh/ and follow instructions"
exit 1
fi
brew install zsh git which
fi
}
get_zshrc() {
log "Downloading .zshrc file"
curl -o ~/.zshrc https://gist.githubusercontent.com/pozgo/abd32ae8d273ab922d1780daf5f7ae67/raw/61c5f87e864231631920062a0980c27463c29dce/.zshrc
}
set_as_default() {
chsh -s $(which zsh)
}
install_theme() {
log "Installing powerlevel9 Theme..."
git clone https://github.com/bhilburn/powerlevel9k.git ~/.oh-my-zsh/custom/themes/powerlevel9k
log "Theme installed."
log "Installing missing fonts"
mkdir -p ~/.fonts/
curl -o ~/.fonts/SourceCodePro%2BPowerline%2BAwesome%2BRegular.ttf https://github.com/gabrielelana/awesome-terminal-fonts/raw/patching-strategy/patched/SourceCodePro%2BPowerline%2BAwesome%2BRegular.ttf
fc-cache -vf ~/.fonts
log "Fonts installed"
}
install_ohmyzsh() {
log " Installing Oh My Zsh..."
curl -o ${PWD}/ohmyzsh.sh https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh
chmod +x ${PWD}/ohmyzsh.sh
sed -n -i '/env zsh/!p' ${PWD}/ohmyzsh.sh
./ohmyzsh.sh
rm -f ohmyzsh.sh
log "OHMYZSH Installed!!"
}
install_packages
install_ohmyzsh
install_theme
get_zshrc
set_as_default
env zsh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment