Last active
April 23, 2018 06:45
-
-
Save andrepearce/863e38adddce891c9a3dadda99c1958e to your computer and use it in GitHub Desktop.
OSX Shell Configuration - with Zsh
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 -e | |
# Make sure brew is installed | |
if hash brew 2>/dev/null; then | |
printf "Brew is already installed!\n" | |
else | |
printf "ERROR: Please install brew before running this script.\n" | |
exit 1 | |
fi | |
# Make sure git is installed | |
if hash git 2>/dev/null; then | |
printf "Git is already installed!\n" | |
else | |
printf "ERROR: Please install git before running this script.\n" | |
exit 1 | |
fi | |
# Install zsh | |
if hash zsh 2>/dev/null; then | |
printf "Zsh is already installed!\n" | |
else | |
printf "Installing zsh...\n" | |
brew install zsh | |
printf "Installed zsh.\n" | |
fi | |
# Install oh-my-zsh | |
printf "Install Oh My Zsh...\n" | |
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" | |
printf "Installed Oh My Zsh.\n" | |
# Install Powerline fonts | |
printf "Installing powerline fonts...\n" | |
git clone https://github.com/powerline/fonts.git --depth=1 | |
./fonts/install.sh | |
rm -rf fonts | |
printf "Installed powerline fonts.\n" | |
# Fetch zsh-syntax-highlighting plugin | |
printf "Fetching zsh-syntax-highlighting plugin...\n" | |
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting | |
printf "Fetched zsh-syntax-highlighting plugin.\n" | |
# Fetch zsh-completions | |
printf "Fetching zsh-completions plugin...\n" | |
git clone https://github.com/zsh-users/zsh-completions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-completions | |
printf "Fetched zsh-completions plugin.\n" | |
# Fetch zsh-autosuggestions | |
printf "Fetching zsh-autosuggestions plugin...\n" | |
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions | |
printf "Fetched zsh-autosuggestions plugin.\n" | |
# Configure .zshrc file | |
printf "Backing up original .zshrc...\n" | |
mv ~/.zshrc ~/.zshrc.bak | |
printf "Configuring .zshrc...\n" | |
cat <<EOF > ~/.zshrc | |
# Path to your oh-my-zsh installation. | |
export ZSH=~/.oh-my-zsh | |
# Theme | |
ZSH_THEME="agnoster" | |
# Enable plugins | |
plugins=( | |
git | |
osx | |
common-aliases | |
dirhistory | |
sudo | |
web-search | |
zsh-syntax-highlighting | |
zsh-completions | |
zsh-autosuggestions | |
docker | |
) | |
source $ZSH/oh-my-zsh.sh | |
# Remove hostname from terminal by setting default user | |
DEFAULT_USER= | |
EOF | |
sed -i -e 's/DEFAULT_USER=/DEFAULT_USER='${USER}'/' ~/.zshrc | |
printf "Configured .zshrc.\n" | |
# Configure .vimrc file | |
printf "Configuring .vimrc...\n" | |
if [ -f ~/.vimrc ]; then | |
mv ~/.vimrc ~/.vimrc.bak | |
fi | |
cat <<EOF > ~/.vimrc | |
syntax on | |
set number | |
EOF | |
printf "Configured .vimrc.\n" | |
# Notify to setup terminal to use a powerline font | |
printf "Configuration complete!\n\n" | |
printf "NOTE: Please ensure you set your terminals font to one of the powerline fonts.\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment