#!/bin/sh set -e THEME=powerlevel10k/powerlevel10k PLUGINS="" ZSHRC_APPEND="" while getopts ":t:p:a:" opt; do case ${opt} in t) THEME=$OPTARG ;; p) PLUGINS="${PLUGINS}$OPTARG " ;; a) ZSHRC_APPEND="$ZSHRC_APPEND\n$OPTARG" ;; \?) echo "Invalid option: $OPTARG" 1>&2 ;; :) echo "Invalid option: $OPTARG requires an argument" 1>&2 ;; esac done shift $((OPTIND -1)) echo echo "Installing Oh-My-Zsh with:" echo " THEME = $THEME" echo " PLUGINS = $PLUGINS" echo check_dist() { ( . /etc/os-release echo $ID ) } check_version() { ( . /etc/os-release echo $VERSION_ID ) } install_dependencies() { DIST=`check_dist` VERSION=`check_version` echo "###### Installing dependencies for $DIST" if [ "`id -u`" = "0" ]; then Sudo='' elif which sudo; then Sudo='sudo' else echo "WARNING: 'sudo' command not found. Skipping the installation of dependencies. " echo "If this fails, you need to do one of these options:" echo " 1) Install 'sudo' before calling this script" echo "OR" echo " 2) Install the required dependencies: git curl zsh" return fi case $DIST in alpine) $Sudo apk add --update --no-cache git curl zsh ;; centos | amzn) $Sudo yum update -y $Sudo yum install -y git curl $Sudo yum install -y ncurses-compat-libs # this is required for AMZN Linux (ref: https://github.com/emqx/emqx/issues/2503) $Sudo curl http://mirror.ghettoforge.org/distributions/gf/el/7/plus/x86_64/zsh-5.1-1.gf.el7.x86_64.rpm > zsh-5.1-1.gf.el7.x86_64.rpm $Sudo rpm -i zsh-5.1-1.gf.el7.x86_64.rpm $Sudo rm zsh-5.1-1.gf.el7.x86_64.rpm ;; *) $Sudo apt-get update $Sudo apt-get -y install git curl zsh locales if [ "$VERSION" != "14.04" ]; then $Sudo apt-get -y install locales-all fi $Sudo locale-gen en_US.UTF-8 esac } zshrc_template() { _HOME=$1; _THEME=$2; shift; shift _PLUGINS=$*; cat < $HOME/.zshrc # Install powerlevel10k if no other theme was specified if [ "$THEME" = "powerlevel10k/powerlevel10k" ]; then git clone https://github.com/romkatv/powerlevel10k $HOME/.oh-my-zsh/custom/themes/powerlevel10k powerline10k_config >> $HOME/.zshrc fi