Skip to content

Instantly share code, notes, and snippets.

@siberex
Last active September 3, 2020 16:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save siberex/307752ba61a65a1876b1f8514b106012 to your computer and use it in GitHub Desktop.
Save siberex/307752ba61a65a1876b1f8514b106012 to your computer and use it in GitHub Desktop.
Oh-My-Zsh MacOs setup

Based on https://gist.github.com/kevin-smets/8568070

  1. Install iTerm2

  2. Install Git

  3. Import patched Solarized Dark under Settings → Profiles → Colors → Color Presets…

More info on patched vs vanilla Solarized Dark:

In short: non-patched Solarized Dark will render some text invisible (for example, zsh-autosuggestions).

For autosuggestions this could be easily fixed by adding ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=#586d74,light".

But there are no such fixes for every other app which want to output text in “Bright Black” color (only solution is to change Bright Black to something brighter than Normal Black in Settings → Profiles → Colors).

On the other hand, patched Solarized Dark introduces rendering issue with Solarized Dark theme for Vim.

So, either Solarized Dark for Vim should be patched too, or just use another color scheme for vim alongside with patched Solarized Dark for iTerm2. For example, Primary works well for me.

Feel free to use patched Solarized Dark for default Terminal too (don’t forget to also set appropriate fonts).

  1. Install Homebrew:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  1. Install Oh My Zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

Configure homebrew completions by updating ~/.zshrc:

# This must be done before compinit is called, i.e. before you call oh-my-zsh.sh
if type brew &>/dev/null; then
  FPATH=$(brew --prefix)/share/zsh/site-functions:$FPATH
fi
  1. Install Source Code Pro for Powerline font.

Set under Settings → Profiles → Text.

Important: Check “Use built-in Powerline glyphs”.

  1. Configure ~/.zshrc:
ZSH_THEME="agnoster"
# User configuration
# ...

hash -d icloud="$HOME/Library/Mobile Documents/com~apple~CloudDocs/"
alias icloud="cd ~icloud"

export HOMEBREW_NO_ANALYTICS=1
DEFAULT_USER=$(whoami)
  1. Install zsh syntax highlighting
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
  1. Install zsh autosuggestions
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
  1. Enable word jumps with arrow keys: Preferences → Profiles → Keys → Preset... → Natural Text Editing

  2. Set up syntax highlighting for Vim:

mkdir -p ~/.vim/pack/default/start
git clone https://github.com/sheerun/vim-polyglot ~/.vim/pack/default/start/vim-polyglot
mkdir -p ~/.vim/colors
curl -L -o ~/.vim/colors/primary.vim https://raw.githubusercontent.com/google/vim-colorscheme-primary/master/colors/primary.vim
  • Update ~/.vimrc:
syntax on
set t_Co=256
set background=dark
colorscheme primary
  1. Update custom plugins whenever needed:
cd ~/.oh-my-zsh/custom/plugins
find . -type d -depth 1 -exec git --git-dir={}/.git --work-tree=$PWD/{} pull origin master \;
set ruler
filetype plugin indent on
syntax on
set t_Co=256
set background=dark
colorscheme primary
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH="$HOME/.oh-my-zsh"
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
ZSH_THEME="agnoster"
# Set list of themes to pick from when loading at random
# Setting this variable when ZSH_THEME=random will cause zsh to load
# a theme from this variable instead of looking in ~/.oh-my-zsh/themes/
# If set to an empty array, this variable will have no effect.
# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" )
# Uncomment the following line to use case-sensitive completion.
# CASE_SENSITIVE="true"
# Uncomment the following line to use hyphen-insensitive completion.
# Case-sensitive completion must be off. _ and - will be interchangeable.
# HYPHEN_INSENSITIVE="true"
# Uncomment the following line to disable bi-weekly auto-update checks.
# DISABLE_AUTO_UPDATE="true"
# Uncomment the following line to automatically update without prompting.
DISABLE_UPDATE_PROMPT="true"
# Uncomment the following line to change how often to auto-update (in days).
# export UPDATE_ZSH_DAYS=13
# Uncomment the following line if pasting URLs and other text is messed up.
# DISABLE_MAGIC_FUNCTIONS=true
# Uncomment the following line to disable colors in ls.
# DISABLE_LS_COLORS="true"
# Uncomment the following line to disable auto-setting terminal title.
# DISABLE_AUTO_TITLE="true"
# Uncomment the following line to enable command auto-correction.
# ENABLE_CORRECTION="true"
# Uncomment the following line to display red dots whilst waiting for completion.
# COMPLETION_WAITING_DOTS="true"
# Uncomment the following line if you want to disable marking untracked files
# under VCS as dirty. This makes repository status check for large repositories
# much, much faster.
# DISABLE_UNTRACKED_FILES_DIRTY="true"
# Uncomment the following line if you want to change the command execution time
# stamp shown in the history command output.
# You can set one of the optional three formats:
# "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# or set a custom format using the strftime function format specifications,
# see 'man strftime' for details.
# HIST_STAMPS="mm/dd/yyyy"
# Would you like to use another custom folder than $ZSH/custom?
# ZSH_CUSTOM=/path/to/new-custom-folder
### gcloud setup for oh-my-zsh
# No need to source google-cloud-sdk/path.zsh.inc and completion.zsh.inc
# as long as gcloud oh-my-zsh plugin loaded
CLOUDSDK_HOME="$HOME/Applications/google-cloud-sdk"
# Homebrew completions.
# This must be done before compinit is called.
# Note that if you are using Oh My Zsh, it will call compinit for you, so this must be done before you call oh-my-zsh.sh.
if type brew &>/dev/null; then
FPATH=$(brew --prefix)/share/zsh/site-functions:$FPATH
fi
# Which plugins would you like to load?
# Standard plugins can be found in ~/.oh-my-zsh/plugins/*
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(
git
osx
docker
extract
helm
heroku
kubectl
gcloud
# https://github.com/jackwish/bazel
# bazel
zsh-autosuggestions
# zsh-syntax-highlighting must be the last plugin sourced
zsh-syntax-highlighting
)
source $ZSH/oh-my-zsh.sh
# User configuration
# export MANPATH="/usr/local/man:$MANPATH"
export GOPATH="$HOME/go"
export PATH="$PATH:$HOME/Applications/bin"
export PATH="$PATH:$HOME/Applications/flutter/bin"
export PATH="$PATH:$GOPATH/bin"
export JAVA_HOME=`/usr/libexec/java_home -v 11.0.5`
# You may need to manually set your language environment
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
export LC_COLLATE=en_US.UTF-8
# Preferred editor for local and remote sessions
# if [[ -n $SSH_CONNECTION ]]; then
# export EDITOR='vim'
# else
# export EDITOR='mvim'
# fi
# Compilation flags
# export ARCHFLAGS="-arch x86_64"
# Set personal aliases, overriding those provided by oh-my-zsh libs,
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
# For a full list of active aliases, run `alias`.
#
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"
hash -d icloud="$HOME/Library/Mobile Documents/com~apple~CloudDocs/"
alias icloud="cd ~icloud"
alias ll='ls -laG'
alias ls='ls -G'
alias cat='bat --plain'
alias telnet='nc'
alias top='sudo htop'
alias ncdu='sudo ncdu --exclude-firmlinks'
alias goclean='go clean -cache -modcache -i -r'
alias docker-node='docker run -it --rm -v "$PWD":/app -w /app --entrypoint=/bin/bash node:latest'
alias docker-ubuntu='docker run -it --rm -v "$PWD":/app -w /app --entrypoint=/bin/bash ubuntu:latest'
alias docker-bazel='docker run -it --rm -v "$PWD":/app -v /var/run/docker.sock:/var/run/docker.sock -w /app --entrypoint=/bin/bash l.gcr.io/google/bazel:latest'
export HOMEBREW_NO_ANALYTICS=1
export CLICOLOR=1
export LSCOLORS=ExFxCxDxBxegedabagacad
export BAT_THEME="TwoDark"
export CLOUDSDK_PYTHON=python3
DEFAULT_USER=$(whoami)
# Fix for Solarized Dark theme (non-patched)
# ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=#586d74,light"
ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE=100
test -e "${HOME}/.iterm2_shell_integration.zsh" && source "${HOME}/.iterm2_shell_integration.zsh"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment