Skip to content

Instantly share code, notes, and snippets.

@blacksun1
Last active July 2, 2018 10:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blacksun1/ab0c3dbbdbbfe125c61c9c5366b022e0 to your computer and use it in GitHub Desktop.
Save blacksun1/ab0c3dbbdbbfe125c61c9c5366b022e0 to your computer and use it in GitHub Desktop.
.zshrc
# Path to your oh-my-zsh installation.
export ZSH=/Users/bruces/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
# ZSH_THEME="ys"
ZSH_THEME="materialshelldark"
# ZSH_THEME="random"
# 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=(aws brew docker git grunt gulp node npm nvm osx sublime sudo vagrant colorize colored-man-pages z)
source $ZSH/oh-my-zsh.sh
# 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='code --wait'
fi
# Compilation flags
# export ARCHFLAGS="-arch x86_64"
# ssh
# export SSH_KEY_PATH="~/.ssh/dsa_id"
# export SSH_KEY_PATH="~/.ssh/id_dsa"
# 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"
#
#
# eval "$(thefuck --alias)"
# Insert own custom zsh completion functions folder
# alias cdgit='cd ~/Projects/; ls'
# fpath=(~/.zsh/completions $fpath)
# compinit
# Initialise nvm
# export NVM_DIR="$HOME/.nvm"
# [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
# # Initialise JRE (Java Runtime Environment)
# export JAVA_HOME='/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home'
# export PATH=${JAVA_HOME}/bin:$PATH
# Initialise cdgit
# export GIT_FOLDER=/Users/bruces/Projects
# source ~/Projects/cdgit/cdgit
# export NODE_HEAPDUMP_OPTIONS=nosignal
source ~/.zshrc_custom.sh
#!/bin/zsh
# NVM
export NVM_DIR="${HOME}/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
# CDGIT!
function cdgit() {
green="\e[38;5;2m"
blue="\e[38;5;4m"
cyan="\e[38;5;6m"
echo -e "${green} ________.______________ "
echo -e "${blue} / _____/| \__ ___/ "
echo -e "${blue}/ \ ___| | | | "
echo -e "${cyan}\ \_\ \ | | | "
echo -e "${green} \______ /___| |____| `git --version`${cyan},${green} node `node --version`${cyan},${green} npm `npm --version`"
echo -e "${green} \/ `pwd`"
cd ~/Projects/ || echo -e "${green} OOOPS! Folder is missing!"
ls
}
# LS_COLORS
#
# di = directory
# fi = file
# ln = symbolic link
# pi = fifo file
# so = socket file
# bd = block (buffered) special file
# cd = character (unbuffered) special file
# or = symbolic link pointing to a non-existent file (orphan)
# mi = non-existent file pointed to by a symbolic link (visible when you type ls -l)
# ex = file which is executable (ie. has 'x' set in permissions).
function
ANSI_NORMAL='=38;5;8'
ANSI_FILE='=38;5;12'
ANSI_FILE_EXECUTABLE='=38;5;2'
ANSI_FILE_LINK='=38;5;12'
ANSI_FILE_LINK_MISSING="=38;5;1"
ANSI_FOLDER='=38;5;4'
ANSI_FOLDER_OTHERS_STICKY='=38;5;1;3'
ANSI_FOLDER_OTHERS_NO_STICKY='=38;5;1;3'
ANSI_CODE_ARTIFACT='=38;5;3'
ANSI_DOCUMENT='=38;5;6'
ANSI_PICTURE='=38;5;9'
ANSI_LEAVE_THIS_ALONE='=38;5;9'
ANSI_DANGER='=38;5;1'
LS_COLORS=""
LS_COLORS=${LS_COLORS}:"*.pem${ANSI_DANGER}"
LS_COLORS=${LS_COLORS}:"*known_hosts${ANSI_DANGER}"
LS_COLORS=${LS_COLORS}:"*id_rsa${ANSI_DANGER}"
LS_COLORS=${LS_COLORS}:"*id_dsa${ANSI_DANGER}"
LS_COLORS=${LS_COLORS}:"*authorized_keys${ANSI_DANGER}"
LS_COLORS=${LS_COLORS}:"*.pgpass${ANSI_DANGER}"
LS_COLORS=${LS_COLORS}:"*.pub${ANSI_LEAVE_THIS_ALONE}"
LS_COLORS=${LS_COLORS}:"*.js${ANSI_CODE_ARTIFACT}"
LS_COLORS=${LS_COLORS}:"*.json${ANSI_CODE_ARTIFACT}"
LS_COLORS=${LS_COLORS}:"*.yml${ANSI_CODE_ARTIFACT}"
LS_COLORS=${LS_COLORS}:"*.yml${ANSI_CODE_ARTIFACT}"
LS_COLORS=${LS_COLORS}:"*.yaml${ANSI_CODE_ARTIFACT}"
LS_COLORS=${LS_COLORS}:"*.htm${ANSI_CODE_ARTIFACT}"
LS_COLORS=${LS_COLORS}:"*.html${ANSI_CODE_ARTIFACT}"
LS_COLORS=${LS_COLORS}:"*.cloudformation${ANSI_CODE_ARTIFACT}"
LS_COLORS=${LS_COLORS}:"*.cfndsl${ANSI_CODE_ARTIFACT}"
LS_COLORS=${LS_COLORS}:"*Dockerfile${ANSI_CODE_ARTIFACT}"
LS_COLORS=${LS_COLORS}:"*.sql${ANSI_CODE_ARTIFACT}"
LS_COLORS=${LS_COLORS}:"*.xml${ANSI_CODE_ARTIFACT}"
LS_COLORS=${LS_COLORS}:"*.md${ANSI_DOCUMENT}"
LS_COLORS=${LS_COLORS}:"*.doc${ANSI_DOCUMENT}"
LS_COLORS=${LS_COLORS}:"*.docx${ANSI_DOCUMENT}"
LS_COLORS=${LS_COLORS}:"*.markdown${ANSI_DOCUMENT}"
LS_COLORS=${LS_COLORS}:"*.txt${ANSI_DOCUMENT}"
LS_COLORS=${LS_COLORS}:"*.text${ANSI_DOCUMENT}"
LS_COLORS=${LS_COLORS}:"*.pdf${ANSI_DOCUMENT}"
LS_COLORS=${LS_COLORS}:"*.csv${ANSI_DOCUMENT}"
LS_COLORS=${LS_COLORS}:"*.xls${ANSI_DOCUMENT}"
LS_COLORS=${LS_COLORS}:"*.xlsx${ANSI_DOCUMENT}"
LS_COLORS=${LS_COLORS}:"*.log${ANSI_DOCUMENT}"
LS_COLORS=${LS_COLORS}:"*.gif${ANSI_DOCUMENT}"
LS_COLORS=${LS_COLORS}:"*.jpg${ANSI_DOCUMENT}"
LS_COLORS=${LS_COLORS}:"*.jpeg${ANSI_DOCUMENT}"
LS_COLORS=${LS_COLORS}:"*.png${ANSI_DOCUMENT}"
LS_COLORS=${LS_COLORS}:"*.sgml${ANSI_DOCUMENT}"
LS_COLORS=${LS_COLORS}:"*.png${ANSI_DOCUMENT}"
# LS_COLORS=${LS_COLORS}:"*node_modules${ANSI_LEAVE_THIS_ALONE}" # They don't work as
# LS_COLORS=${LS_COLORS}:"*.git${ANSI_LEAVE_THIS_ALONE}" # they are folders
LS_COLORS=${LS_COLORS}:"*.gitignore${ANSI_LEAVE_THIS_ALONE}"
LS_COLORS=${LS_COLORS}:"*.gitconfig${ANSI_LEAVE_THIS_ALONE}"
LS_COLORS=${LS_COLORS}:"*.editorconfig${ANSI_LEAVE_THIS_ALONE}"
LS_COLORS=${LS_COLORS}:"*.jsdoc${ANSI_LEAVE_THIS_ALONE}"
LS_COLORS=${LS_COLORS}:"*rc${ANSI_LEAVE_THIS_ALONE}"
LS_COLORS=${LS_COLORS}:"no${ANSI_NORMAL}"
LS_COLORS=${LS_COLORS}:"fi${ANSI_FILE}"
LS_COLORS=${LS_COLORS}:"ln${ANSI_FILE_LINK}"
LS_COLORS=${LS_COLORS}:"mi${ANSI_FILE_LINK_MISSING}"
LS_COLORS=${LS_COLORS}:"ex${ANSI_FILE_EXECUTABLE}"
LS_COLORS=${LS_COLORS}:"di${ANSI_FOLDER}"
LS_COLORS=${LS_COLORS}:"tw${ANSI_FOLDER_OTHERS_STICKY}"
LS_COLORS=${LS_COLORS}:"ow${ANSI_FOLDER_OTHERS_NO_STICKY}"
export LS_COLORS
# JRE (Java Runtime Environment)
# export JAVA_HOME='/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home'
# JDK (Java Development Kit)
export JAVA_HOME='/Library/Java/JavaVirtualMachines/jdk-10.0.1.jdk/Contents/Home'
export PATH=${JAVA_HOME}/bin:$PATH
# RVM
# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.
# export PATH="$PATH:$HOME/.rvm/bin"
# source ~/.rvm/scripts/rvm
# Setup GO
# export GOROOT=/usr/local/go
# export GOPATH=$HOME/Projects/Proj1
# export PATH=$GOPATH/bin:$GOROOT/bin:$PATH
# export PATH=${GOROOT}/bin:${PATH}
# Setup PGSQL
source ${HOME}/Projects/psql-scripts/load-scripts.sh
export PATH="/usr/local/opt/postgresql@9.6/bin:$PATH"
# Turn on color
export CLICOLOR=1
test -e "${HOME}/.iterm2_shell_integration.zsh" && source "${HOME}/.iterm2_shell_integration.zsh"
# Local bin path
[ -d ~/bin ] || mkdir ~/bin && export PATH=${HOME}/bin:${PATH}
# Oh-My-Zsh : Nico Theme (https://gist.github.com/ntarocco/3027ed75b6e8fc1fd119)
# Modified by : Carlos Cuesta
eval red='$FG[203]'
eval green='$FG[184]'
eval yellow='$FG[220]'
eval blue='$FG[075]'
eval magenta='$FG[161]'
eval cyan='$FG[037]'
eval white='$FG[231]'
eval grey='$FG[145]'
PROMPT='$(_user_host)${_current_dir}$(git_prompt_info)
%{$white%}>%{$reset_color%} '
PROMPT2='%{$grey%}◀%{$reset_color%} '
#RPROMPT='$(_vi_status)%{$(echotc UP 1)%}$(git_prompt_short_sha) $(_git_time_since_commit) ${_return_status} %T% %{$(echotc DO 1)%}'
RPROMPT='$(_vi_status)%{$(echotc UP 1)%}$(git_prompt_short_sha) ${_return_status} %{$white%}%T%{$(echotc DO 1)%}%{$reset_color%}'
local _current_dir="%{$green%}%0~%{$reset_color%} "
local _return_status="%{$red%}%(?..×)%{$reset_color%}"
local _hist_no="%{$grey%}%h%{$reset_color%}"
function _user_host() {
echo "%{$red%}%n%{$reset_color%}%{$white%} at %{$yellow%}%m%{$reset_color%} %{$white%}in "
}
function _vi_status() {
if {echo $fpath | grep -q "plugins/vi-mode"}; then
echo "$(vi_mode_prompt_info)"
fi
}
function _ruby_version() {
if {echo $fpath | grep -q "plugins/rvm"}; then
echo "%{$grey%}$(rvm_prompt_info)%{$reset_color%}"
fi
}
# Determine the time since last commit. If branch is clean,
# use a neutral color, otherwise colors will vary according to time.
function _git_time_since_commit() {
if git rev-parse --git-dir > /dev/null 2>&1; then
# Only proceed if there is actually a commit.
if [[ $(git log 2>&1 > /dev/null | grep -c "^fatal: bad default revision") == 0 ]]; then
# Get the last commit.
last_commit=$(git log --pretty=format:'%at' -1 2> /dev/null)
now=$(date +%s)
seconds_since_last_commit=$((now-last_commit))
# Totals
minutes=$((seconds_since_last_commit / 60))
hours=$((seconds_since_last_commit/3600))
# Sub-hours and sub-minutes
days=$((seconds_since_last_commit / 86400))
sub_hours=$((hours % 24))
sub_minutes=$((minutes % 60))
if [ $hours -gt 24 ]; then
commit_age="${days}d"
elif [ $minutes -gt 60 ]; then
commit_age="${sub_hours}h${sub_minutes}m"
else
commit_age="${minutes}m"
fi
color=$ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL
echo "$color$commit_age%{$reset_color%}"
fi
fi
}
if [[ $USER == "root" ]]; then
CARETCOLOR="$red"
else
CARETCOLOR="$white"
fi
MODE_INDICATOR="%{_bold$yellow%}❮%{$reset_color%}%{$yellow%}❮❮%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_PREFIX="%{$white%}on %{$blue%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
ZSH_THEME_GIT_PROMPT_DIRTY=" %{$red%}✗%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_CLEAN=" %{$green%}✔%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_ADDED=" %{$green%}✚{$reset_color%}"
ZSH_THEME_GIT_PROMPT_MODIFIED=" %{$yellow%}⚑{$reset_color%} "
ZSH_THEME_GIT_PROMPT_DELETED=" %{$red%}✖{$reset_color%} "
ZSH_THEME_GIT_PROMPT_RENAMED=" %{$blue%}▴{$reset_color%} "
ZSH_THEME_GIT_PROMPT_UNMERGED=" %{$cyan%}§{$reset_color%} "
ZSH_THEME_GIT_PROMPT_UNTRACKED=" %{$grey%}◒{$reset_color%} "
# Colors vary depending on time lapsed.
ZSH_THEME_GIT_TIME_SINCE_COMMIT_SHORT="%{$green%}"
ZSH_THEME_GIT_TIME_SHORT_COMMIT_MEDIUM="%{$yellow%}"
ZSH_THEME_GIT_TIME_SINCE_COMMIT_LONG="%{$red%}"
ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL="%{$yellow%}"
# Format for git_prompt_long_sha() and git_prompt_short_sha()
ZSH_THEME_GIT_PROMPT_SHA_BEFORE="%{$reset_color%}[%{$yellow%}"
ZSH_THEME_GIT_PROMPT_SHA_AFTER="%{$reset_color%}]"
# LS colors, made with http://geoff.greer.fm/lscolors/
export LSCOLORS="exfxcxdxbxegedabagacad"
export LS_COLORS='di=34;40:ln=35;40:so=32;40:pi=33;40:ex=31;40:bd=34;46:cd=34;43:su=0;41:sg=0;46:tw=0;42:ow=0;43:'
export GREP_COLOR='1;33'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment