Skip to content

Instantly share code, notes, and snippets.

@KuangyeChen
Last active January 7, 2023 03:28
Show Gist options
  • Save KuangyeChen/aa85856754acab29bef66b7eac582f82 to your computer and use it in GitHub Desktop.
Save KuangyeChen/aa85856754acab29bef66b7eac582f82 to your computer and use it in GitHub Desktop.
Install oh-my-zsh related stuff.
#!/usr/bin/env bash
set -e
function log_section() {
printf "\033[0;32m==>\033[0m\033[1m ${*}\033[0m\n"
}
function log_warning() {
printf "\033[1mWARN\033[0m: ${*}\n"
}
function log_error() {
printf "\033[1mERROR\033[0m: ${*}\n"
}
function safe_git_clone() {
if [[ ! -d ${2} ]]; then
git clone ${1} ${2}
else
log_warning "${2} exists, do nothing."
fi
}
log_section "Install Oh-My-Zsh"
if [[ ! -d ${HOME}/.oh-my-zsh ]]; then
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended
fi
log_section "Change default shell to Zsh"
if [[ "$(grep ${USER} </etc/passwd | cut -f 7 -d ":")" != "/bin/zsh" ]]; then
sudo chsh -s /bin/zsh ${USER}
fi
ZSH_CUSTOM="${HOME}/.oh-my-zsh/custom"
log_section "Install Oh-My-Zsh Themes and Plugins"
safe_git_clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM}/plugins/zsh-autosuggestions
safe_git_clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM}/plugins/zsh-syntax-highlighting
safe_git_clone https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
if [[ ${OSTYPE} == linux-gnu ]]; then
sudo apt-get -y update && sudo apt-get -y install fonts-powerline
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment