Skip to content

Instantly share code, notes, and snippets.

@Joaquin6
Last active July 18, 2017 10:50
Show Gist options
  • Select an option

  • Save Joaquin6/b25428a480a1ce28753fdd3c0fe8ee74 to your computer and use it in GitHub Desktop.

Select an option

Save Joaquin6/b25428a480a1ce28753fdd3c0fe8ee74 to your computer and use it in GitHub Desktop.
ZSH Antigen - Hidden ".zshrc" and ".bash_profile" files that works without errors
# ---------------------------------------------------------------------------
#
# Description: This file holds all my BASH configurations and aliases
#
# Sections:
# 1. Environment Configuration
# 2. Make Terminal Better (remapping defaults and adding functionality)
# 3. File and Folder Management
# 4. Searching
# 5. Process Management
# 6. Networking
# 7. System Operations & Information
# 8. Web Development
# 9. Reminders & Notes
#
# ---------------------------------------------------------------------------
# CONFIGURATION VARIABLES
# -------------------------------
RUBY_VERSION=2.4.0
HOME_LIB_PATH=$HOME/Library
SYS_LIB_PATH=/System/Library
SYS_FRWKS_PATH=$SYS_LIB_PATH/Frameworks
USER_BIN=/usr/bin
USER_LOCAL=/usr/local
USER_LOCAL_BIN=$USER_LOCAL/bin
USER_LOCAL_SBIN=$USER_LOCAL/sbin
USER_LOCAL_SHARE=$USER_LOCAL/share
USER_LOCAL_LIB=$USER_LOCAL/lib
USER_LOCAL_OPT=$USER_LOCAL/opt
USER_BIN_PATH=/bin:/sbin:/usr/sbin:$USER_BIN:$USER_LOCAL_BIN
XDG_CONFIG_HOME=$HOME/.config
# -------------------------------
# 1. ENVIRONMENT CONFIGURATION
# -------------------------------
# export AWS_RDS_HOME=$HOME/AWS
# export AWS_CREDENTIAL_FILE=$HOME/AWS/aws-credentials
export PATH=/opt/bin:$PATH
export DOTFILES=$HOME/bin/dotfiles
export HIVE_HOME=$USER_LOCAL/hive
export NVM_DIR=$HOME/.nvm
export GEM_DIR=$HOME/.gem
export RUBY_PATH=$GEM_DIR/ruby/$RUBY_VERSION
export RUBY_GEM_PATH=$USER_LOCAL_LIB/ruby/gems/$RUBY_VERSION/gems
export NVM_NODE_VERSION_PATH=$NVM_DIR/versions/node
export PKG_CONFIG_PATH=$USER_LOCAL_OPT/libressl/lib/pkgconfig
export LDFLAGS=-L$USER_LOCAL_OPT/libressl/lib
export CPPFLAGS=-I$USER_LOCAL_OPT/libressl/include
export CLASSPATH=$CLASSPATH:$USER_LOCAL/Hadoop/lib/*:.
export CLASSPATH=$CLASSPATH:$USER_LOCAL/hive/lib/*:.
# Set Paths
# ------------------------------------------------------------
# export PATH=$PATH:$AWS_RDS_HOME
export PATH=$PATH:$USER_BIN_PATH:$USER_LOCAL:$USER_LOCAL_BIN:$USER_LOCAL_SBIN:$USER_LOCAL_SHARE:$USER_LOCAL/git/bin
export PATH=$PATH:$RUBY_PATH/bin:$USER_LOCAL_OPT/libressl/bin
export PATH=$PATH:$NVM_NODE_VERSION_PATH/v7.10.0/bin/npm/bin
# Adding an appropriate PATH variable for use with MacPorts.
export PATH=$USER_LOCAL/pgsql/bin:/opt/local/bin:/opt/local/sbin:~/.rbenv/shims:$PATH
export PATH=$PATH:$HIVE_HOME/bin
export PATH=$HOME/.rbenv/bin:$PATH
export PATH=$HOME/.nodebrew/current/bin:$PATH
export PATH=/opt/bin:$PATH
# Set Default Editor (change 'Nano' to the editor of your choice)
# ------------------------------------------------------------
export GIT_EDITOR="vim"
export EDITOR="$USER_LOCAL_BIN/subl -n -w" # Setting Sublime as the default editor
export PAGER='less'
# export EDITOR="/usr/local/bin/subl"
export GEM_PATH=$USER_LOCAL_BIN:$RUBY_PATH:$RUBY_GEM_PATH:$GEM_PATH
export GEM_PATH=$RUBY_GEM_PATH/sass-3.4.23/bin:$GEM_PATH
# Add color to terminal
# from http://osxdaily.com/2012/02/21/add-color-to-the-terminal-in-mac-os-x/
# ------------------------------------------------------------
# Colors for Dark Terminal Themes
# export CLICOLOR=1
# export LSCOLORS=GxFxCxDxBxegedabagaced
# ssh
export SSH_KEY_PATH=$HOME/.ssh/id_rsa
# servers
# export PROD=ubuntu@prd-wb.aws.lbox.com
# export INT=ubuntu@schems-wb1.aws.lbox.com
export SHELL=/bin/zsh
[ -z "$ZSH_VERSION" ] && exec /bin/zsh -l
# -----------------------------
# 2. MAKE TERMINAL BETTER
# -----------------------------
alias l='ls -la'
alias sl=ls
alias ls='ls -GFh' # Preferred 'ls' implementation
alias ll='ls -GFlAhp'
alias lr='ls -R | grep ":$" | sed -e '\''s/:$//'\'' -e '\''s/[^-][^\/]*\//--/g'\'' -e '\''s/^/ /'\'' -e '\''s/-/|/'\'' | less'
cd() { builtin cd "$@"; ll; } # Always list directory contents upon 'cd'
alias cd..='cd ../' # Go back 1 directory level (for fast typers)
alias ..='cd ../' # Go back 1 directory level
alias ...='cd ../../' # Go back 2 directory levels
alias .3='cd ../../../' # Go back 3 directory levels
alias .4='cd ../../../../' # Go back 4 directory levels
alias .5='cd ../../../../../' # Go back 5 directory levels
alias .6='cd ../../../../../../' # Go back 6 directory levels
alias edit='subl' # edit: Opens any file in sublime editor
alias f='open -a Finder ./' # f: Opens current directory in MacOS Finder
alias ~="cd ~" # ~: Go Home
alias c='clear' # c: Clear terminal display
alias path='echo -e ${PATH//:/\\n}' # path: Echo all executable Paths
alias show_options='shopt' # Show_options: display bash options settings
alias fix_stty='stty sane' # fix_stty: Restore terminal settings when screwed up
alias cic='set completion-ignore-case On' # cic: Make tab-completion case-insensitive
mcd () { mkdir -p "$1" && cd "$1"; } # mcd: Makes new Dir and jumps inside
trash () { command mv "$@" ~/.Trash ; } # trash: Moves a file to the MacOS trash
ql () { qlmanage -p "$*" >& /dev/null; } # ql: Opens any file in MacOS Quicklook Preview
alias DT='tee ~/Desktop/terminalOut.txt' # DT: Pipe content to file on MacOS Desktop
alias UN='echo $USER' # UN: Echo Username
alias zshconfig="mate ~/.zshrc"
alias ohmyzsh="mate ~/.oh-my-zsh"
# lr: Full Recursive Directory Listing
# ------------------------------------------
alias lr='ls -R | grep ":$" | sed -e '\''s/:$//'\'' -e '\''s/[^-][^\/]*\//--/g'\'' -e '\''s/^/ /'\'' -e '\''s/-/|/'\'' | less'
# showa: to remind yourself of an alias (given some part of it)
# ------------------------------------------------------------
showa () { /usr/bin/grep --color=always -i -a1 $@ ~/Library/init/bash/aliases.bash | grep -v '^\s*$' | less -FSRXc ; }
# for git autocomplete
# ------------------------------------------------------------
if [ -f $(brew --prefix)/etc/bash_completion ]; then
. $(brew --prefix)/etc/bash_completion
fi
# ---------------------------
# 4. SEARCHING
# ---------------------------
alias qfind="find . -name " # qfind: Quickly search for file
ff () { /usr/bin/find . -name "$@" ; } # ff: Find file under the current directory
ffs () { /usr/bin/find . -name "$@"'*' ; } # ffs: Find file whose name starts with a given string
ffe () { /usr/bin/find . -name '*'"$@" ; } # ffe: Find file whose name ends with a given string
# spotlight: Search for a file using MacOS Spotlight's metadata
# -----------------------------------------------------------
spotlight () { mdfind "kMDItemDisplayName == '$@'wc"; }
# ---------------------------
# 5. PROCESS MANAGEMENT
# ---------------------------
# findPid: find out the pid of a specified process
# -----------------------------------------------------
# Note that the command name can be specified via a regex
# E.g. findPid '/d$/' finds pids of all processes with names ending in 'd'
# Without the 'sudo' it will only find processes of the current user
# -----------------------------------------------------
findPid () { lsof -t -c "$@" ; }
# ---------------------------------------
# 7. SYSTEMS OPERATIONS & INFORMATION
# ---------------------------------------
# finderShowHidden: Show hidden files in Finder
# finderHideHidden: Hide hidden files in Finder
# -------------------------------------------------------------------
alias finderShowHidden='defaults write com.apple.finder ShowAllFiles TRUE'
alias finderHideHidden='defaults write com.apple.finder ShowAllFiles FALSE'
# cleanupLS: Clean up LaunchServices to remove duplicates in the "Open With" menu
# -----------------------------------------------------------------------------------
alias cleanupLS="/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user && killall Finder"
# -------------------------------
# 9. FILE AND FOLDER MANAGEMENT
# -------------------------------
alias cdu='cd-gitroot'
alias gst='git status'
alias gc='git commit'
alias gco='git checkout'
alias ga='git add'
alias gl="git log --all --graph --format=format:'%C(bold blue)%h%C(reset) - %C(black)%s%C(reset) %C(bold magenta)%d%C(reset)'"
alias unmount_all_and_exit='unmount_all && exit'
alias pretty='pygmentize -g -O encoding=utf-8'
alias glp="git log --all --graph --pretty=format:'%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative"
# ---------------------------------------
# 10. REMINDERS & NOTES
# ---------------------------------------
# remove_disk: spin down unneeded disk
# ---------------------------------------
# diskutil eject /dev/disk1s3
# to change the password on an encrypted disk image:
# ---------------------------------------
# hdiutil chpass /path/to/the/diskimage
# to mount a read-only disk image as read-write:
# ---------------------------------------
# hdiutil attach example.dmg -shadow /tmp/example.shadow -noverify
# mounting a removable drive (of type msdos or hfs)
# ---------------------------------------
# mkdir /Volumes/Foo
# ls /dev/disk* to find out the device to use in the mount command)
# mount -t msdos /dev/disk1s1 /Volumes/Foo
# mount -t hfs /dev/disk1s1 /Volumes/Foo
# to create a file of a given size: /usr/sbin/mkfile or /usr/bin/hdiutil
# ---------------------------------------
# e.g.: mkfile 10m 10MB.dat
# e.g.: hdiutil create -size 10m 10MB.dmg
# the above create files that are almost all zeros - if random bytes are desired
# then use: ~/Dev/Perl/randBytes 1048576 > 10MB.dat
eval "$(rbenv init -)"
test -e $HOME/.iterm2_shell_integration.zsh && source $HOME/.iterm2_shell_integration.zsh
export SHELL=/bin/zsh
[ -z "$ZSH_VERSION" ] && exec /bin/zsh -l
# Setting PATH for NVM
[ -s "$HOME/.nvm/nvm.sh" ] && . "$HOME/.nvm/nvm.sh"
# If phpbrew is installed include the source
if [ -d $HOME/.phpbrew ]; then
source $HOME/.phpbrew/bashrc
fi
if [ -f /usr/local/bin/virtualenvwrapper.sh ]; then
source /usr/local/bin/virtualenvwrapper.sh
export WORKON_HOME=$HOME/Code/VirtualEnvs
fi
# Change shell for current user to zsh
if [ ! "$SHELL" = "/bin/zsh" ]; then
export SHELL=/bin/zsh
[ -z "$ZSH_VERSION" ] && exec /bin/zsh -l
fi
ZSHA_BASE=$HOME/.zsh-antigen
# Path to your oh-my-zsh installation.
export ZSH=$HOME/.oh-my-zsh
# Would you like to use another custom folder than $ZSH/custom?
export ZSH_CUSTOM=$ZSH/custom
export NVM_AUTO_USE=true
source $ZSHA_BASE/antigen/bin/antigen.zsh
source $ZSHA_BASE/bundles/aws-completion/aws-completion.sh
# Load the oh-my-zsh's library.
antigen use oh-my-zsh
# 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/
antigen bundle aws
antigen bundle git
antigen bundle git-prompt
antigen bundle grunt
antigen bundle ruby
antigen bundle bower
antigen bundle node
antigen bundle nvm
antigen bundle npm
antigen bundle sudo
antigen bundle tmux
antigen bundle sublime
antigen bundle colorize
antigen bundle extract
antigen bundle $ZSHA_BASE/bundles/stv
# Python Plugins
antigen bundle pip
antigen bundle python
antigen bundle virtualenv
# OS specific plugins
if [[ $CURRENT_OS == 'OS X' ]]; then
antigen bundle brew
antigen bundle brew-cask
antigen bundle gem
antigen bundle osx
elif [[ $CURRENT_OS == 'Linux' ]]; then
# None so far...
if [[ $DISTRO == 'CentOS' ]]; then
antigen bundle centos
fi
elif [[ $CURRENT_OS == 'Cygwin' ]]; then
antigen bundle cygwin
fi
# Syntax highlighting bundle.
antigen bundle zsh-users/zsh-history-substring-search
antigen bundle zsh-users/zsh-autosuggestions # https://github.com/zsh-users/zsh-autosuggestions
antigen bundle $ZSHA_BASE/bundles/git-completion
antigen bundle $ZSHA_BASE/bundles/nvm-auto
antigen bundle djui/alias-tips
antigen bundle jocelynmallon/zshmarks # https://github.com/jocelynmallon/zshmarks
antigen bundle dbkaplun/smart-cd # https://github.com/dbkaplun/smart-cd
antigen bundle Tarrasch/zsh-colors # https://github.com/Tarrasch/zsh-colors
antigen bundle lukechilds/zsh-nvm
antigen bundle mafredri/zsh-async # https://github.com/mafredri/zsh-async
antigen bundle sindresorhus/pure
antigen bundle therealklanni/purity # https://github.com/therealklanni/purity
antigen bundle chrissicool/zsh-bash # https://github.com/chrissicool/zsh-bash
antigen bundle peterhurford/git-aliases.zsh # https://github.com/peterhurford/git-aliases.zsh
antigen bundle lukechilds/zsh-better-npm-completion
antigen bundle unixorn/rake-completion.zshplugin # https://github.com/unixorn/rake-completion.zshplugin
# Load the theme.
antigen theme $ZSHA_BASE/themes mgdm
# Tell antigen that you're done.
antigen-apply
# -------------------------------
# 1. ENVIRONMENT CONFIGURATION
# -------------------------------
# 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"
# User configuration
# Homebrew
# This is one of examples why I want to keep my dotfiles private
# export HOMEBREW_GITHUB_API_TOKEN=MY_GITHUB_TOKEN
# export HOMEBREW_CASK_OPTS="--appdir=/Applications"
# export MANPATH=/usr/share/man:$MANPATH
# You may need to manually set your language environment
# export LANG=en_US.UTF-8
# fix django locale issue from here on mac
# export LC_ALL=en_US.UTF-8
# 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"
# FUNCTIONS -------------------------------------------------------------------
# pip zsh completion start
function _pip_completion {
local words cword
read -Ac words
read -cn cword
reply=( $( COMP_WORDS="$words[*]" \
COMP_CWORD=$(( cword-1 )) \
PIP_AUTO_COMPLETE=1 $words[1] ) )
}
compctl -K _pip_completion pip
# pip zsh completion end
# 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
# ALIASES ---------------------------------------------------------------------
# place this after nvm initialization!
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment