Skip to content

Instantly share code, notes, and snippets.

@brianbancroft
Last active February 23, 2018 14:38
Show Gist options
  • Save brianbancroft/f4f4cd4b208f52ae7f2cdf55205774a9 to your computer and use it in GitHub Desktop.
Save brianbancroft/f4f4cd4b208f52ae7f2cdf55205774a9 to your computer and use it in GitHub Desktop.
My zsh config
# 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=/Users/brianbancroft/.oh-my-zsh
# Set name of the theme to load. Optionally, if you set this to "random"
# it'll load a random theme each time that oh-my-zsh is loaded.
ZSH_THEME="powerlevel9k/powerlevel9k"
source ~/.git-completion.bash
# 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 change how often to auto-update (in days).
# export UPDATE_ZSH_DAYS=13
# 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.
# The optional three formats: "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# HIST_STAMPS="mm/dd/yyyy"
# Would you like to use another custom folder than $ZSH/custom?
# ZSH_CUSTOM=/path/to/new-custom-folder
# Which plugins would you like to load? (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, zsh-syntax-highlighting)
source $ZSH/oh-my-zsh.sh
# User configuration
# export MANPATH="/usr/local/man:$MANPATH"
# You may need to manually set your language environment
# export LANG=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"
# ssh
# export SSH_KEY_PATH="~/.ssh/rsa_id"
# 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"
[[ -s "$HOME/.profile" ]] && source "$HOME/.profile" # Load the default .profile
# Set up local environment variables for app development
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
# Automatically load correct nvm version
autoload -U add-zsh-hook
load-nvmrc() {
local node_version="$(nvm version)"
local nvmrc_path="$(nvm_find_nvmrc)"
if [ -n "$nvmrc_path" ]; then
local nvmrc_node_version=$(nvm version "$(cat "${nvmrc_path}")")
if [ "$nvmrc_node_version" = "N/A" ]; then
nvm install
elif [ "$nvmrc_node_version" != "$node_version" ]; then
nvm use
fi
elif [ "$node_version" != "$(nvm version default)" ]; then
echo "Reverting to nvm default version"
nvm use default
fi
}
add-zsh-hook chpwd load-nvmrc
load-nvmrc
# ALIAS
## Run Rails
alias rss="rails s"
alias rcc="rails c"
## Reset Rails DB
alias mrss="rails db:migrate && rails s"
alias mrcc="rails db:migrate && rails c"
alias rgm="rails g migration"
### General
alias start-tests="ember test --server"
alias rebuild-app="rm -rf tmp/ && rm -rf dist/ && rm -rf node_modules/ && rm -rf bower_componets/ && bower cache clean && yarn cache clean && yarn install && bower install"
alias nn="node"
alias kill_rails='kill -9 $(lsof -i tcp:3000 -t)'
alias kill_node='kill -9 $(lsof -i tcp:3000 -t)'
## git
alias g="git"
alias goto-develop="git checkout develop && git pull"
alias goto-develop-damnit="git stash && git checkout develop && git pull"
alias goto='git checkout'
alias gbdd='git branch -d'
alias goto-new='git checkout -b'
alias nb='git checkout -b'
alias merge-develop='git merge develop'
alias end-conflict='git add . && git commit -m "🔀 Update with develop"'
alias kill-branch="git branch -D"
ps -A | grep -m1 Postico | awk '{print $1}'
## Temp Heroku
alias check-sample-app="heroku run bash -a"
## bash
alias edit-zsh="code ~/.zshrc"
alias set-zsh="source ~/.zshrc"
### Static site serving
alias serve-lolcommits="cd ~/.lolcommits/rails-api && serve"
alias f='open -a Finder ./'
### Almost as good as autocorrect
eval $(thefuck --alias)
### ZSH CONFIG
POWERLEVEL9K_MODE='awesome-patched'
POWERLEVEL9K_SHORTEN_DIR_LENGTH=2
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(os_icon dir vcs)
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=('status' 'rvm' 'nvm' 'node_version')
POWERLEVEL9K_PROMPT_ON_NEWLINE=true
POWERLEVEL9K_RPROMPT_ON_NEWLINE=true
POWERLEVEL9K_RVM_BACKGROUND="red"
POWERLEVEL9K_RVM_FOREGROUND="white"
POWERLEVEL9K_RVM_VISUAL_IDENTIFIER_COLOR="white"
POWERLEVEL9K_OS_ICON_BACKGROUND="white"
POWERLEVEL9K_OS_ICON_FOREGROUND="blue"
POWERLEVEL9K_DIR_HOME_FOREGROUND="white"
POWERLEVEL9K_DIR_HOME_SUBFOLDER_FOREGROUND="white"
POWERLEVEL9K_DIR_DEFAULT_FOREGROUND="white"
source /Users/brianbancroft/side-projects/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
export GEM_HOME=~/.gems
export INSTALL_PREFIX="/usr/local"
export CUDA_PREFIX="/usr/local/cuda"
export CUDNN_ENABLED=1
export CUDARRAY_BACKEND=numpy
export LD_LIBRARY_PATH=/usr/local/lib
export LD_LIBRARY_PATH=/usr/local/cuda/lib
export PATH=$PATH:~/.gems/bin
export PATH=$PATH:/usr/local/bin
# export PATH="/Library/Frameworks/Python.framework/Versions/3.4/bin/:usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
# export PYTHONPATH=$PYTHONPATH:/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages
ulimit -n 65536 65536
# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.
export PATH="$HOME/.yarn/bin:$PATH"
alias update-dependencies="rm -rf tmp/ dist/ node_modules && npm install"
function rails() {
if [ "$1" = "kill" ]; then
lsof -ti:3000 | xargs kill
if [ -f tmp/pids/server.pid ]; then
kill $2 $(cat tmp/pids/server.pid)
return 0
else
echo "It seems there is no server running or you are not in a rails project root directory"
return 1
fi
else
command rails $@
fi;
}
# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.
export PATH="$PATH:$HOME/.rvm/bin"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment