Skip to content

Instantly share code, notes, and snippets.

@Joaquin6
Created October 11, 2017 07:08
Show Gist options
  • Save Joaquin6/282cb3af1409becf2883cec12817ff89 to your computer and use it in GitHub Desktop.
Save Joaquin6/282cb3af1409becf2883cec12817ff89 to your computer and use it in GitHub Desktop.
ZSH RC File as of 10/10/2017 with Mac based confiurations
# CONFIGURATION VARIABLES
# -------------------------------
PYTHON_VERSION=2.7
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_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_LIB_PATH/Python/$PYTHON_VERSION/lib/python/site-packages/powerline
# 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.
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
ZSH_THEME="powerlevel9k/powerlevel9k"
export PATH=$HOME/bin:/usr/local/bin:$PATH # If you come from bash you might have to change your $PATH.
export ZSH=$HOME/.oh-my-zsh # Path to your oh-my-zsh installation.
export ZSH_CUSTOM=$ZSH/custom
export ZSHA_BASE=$HOME/.antigen
export ZSH_PLUGINS_ALIAS_TIPS_TEXT="Alias tip: "
export WORKON_HOME=$HOME/.virtualenvs
export PROMPT_COMMAND="${PROMPT_COMMAND:+$PROMPT_COMMAND ;} history -a"
export ADOTDIR=$ZSHA_BASE
export NVM_DIR=$HOME/.nvm
export LDFLAGS=-L$USER_LOCAL_OPT/libressl/lib
export CPPFLAGS=-I$USER_LOCAL_OPT/libressl/include
export SSH_KEY_PATH=$HOME/.ssh/rsa_id
# Browser
if [[ "$OSTYPE" == darwin* ]]; then
export BROWSER='open'
fi
# Editors
export EDITOR='subl -w'
export VISUAL='nano'
export PAGER='less'
# Language
if [[ -z "$LANG" ]]; then
export LANG='en_US.UTF-8'
fi
# Paths
# Ensure path arrays do not contain duplicates.
typeset -gU cdpath fpath mailpath path
# Set the list of directories that cd searches.
cdpath=(
$cdpath
)
# Set the list of directories that Zsh searches for programs.
path=(
/usr/local/{bin,sbin}
$path
)
# Less
# Set the default Less options.
# Mouse-wheel scrolling has been disabled by -X (disable screen clearing).
# Remove -X and -F (exit if the content fits on one screen) to enable it.
export LESS='-g -i -M -R -S -w -z-4'
# export LESS='-F -g -i -M -R -S -w -X -z-4'
# Set the Less input preprocessor.
# Try both `lesspipe` and `lesspipe.sh` as either might exist on a system.
if (( $#commands[(i)lesspipe(|.sh)] )); then
if [[ "$OSTYPE" == darwin* ]]; then
# echo "------- DARWIN SYSTEM --------"
export LESSOPEN="|/usr/local/bin/lesspipe.sh %s" LESS_ADVANCED_PREPROCESSOR=1
else
# echo "------- NON-DARWIN SYSTEM --------"
export LESSOPEN="| /usr/bin/env $commands[(i)lesspipe(|.sh)] %s 2>&-"
fi
fi
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
source $HOME/antigen/antigen.zsh
# if rbenv is present, configure it for use
if which rbenv &> /dev/null; then
# enable shims and auto-completion
if [ -d $HOME/.rbenv ]; then
# Put the rbenv entry at the front of the line
export PATH=$HOME/.rbenv/bin:$PATH
eval "$(rbenv init -)"
fi
fi
# If phpbrew is installed include the source
if [ -d $HOME/.phpbrew ]; then
source $HOME/.phpbrew/bashrc
fi
if [ -f $USER_LOCAL_BIN/virtualenvwrapper.sh ]; then
source $USER_LOCAL_BIN/virtualenvwrapper.sh
export WORKON_HOME=$HOME/Code/VirtualEnvs
fi
antigen use oh-my-zsh
antigen bundles <<EOBUNDLES
aws
git
git-prompt
brew
ruby
gem
rbenv
rsync
sublime
cask
node
npm
sudo
yarn
postgres
docker
docker-compose
man
z
# Python Plugins
pip
python
virtualenv
EOBUNDLES
# OS Based Plugins
if [[ "$OSTYPE" == darwin* ]]; then
antigen bundle osx
fi
antigen bundle zsh-users/zsh-syntax-highlighting # https://github.com/zsh-users/zsh-syntax-highlighting
antigen bundle zsh-users/zsh-history-substring-search # https://github.com/zsh-users/zsh-history-substring-search
antigen bundle zsh-users/zsh-autosuggestions # https://github.com/zsh-users/zsh-autosuggestions
antigen bundle lukechilds/zsh-nvm
antigen bundle djui/alias-tips # https://github.com/djui/alias-tips
antigen bundle jocelynmallon/zshmarks # https://github.com/jocelynmallon/zshmarks
antigen bundle Joaquin6/git-aliases # https://github.com/Joaquin6/git-aliases
# Suuply the theme
antigen theme bhilburn/powerlevel9k powerlevel9k
# Tell antigen that you're done.
antigen apply
# User configuration
# Customise autosuggestion color
ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=green,bold'
# 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"
# 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"
# -----------------------------
# 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 ~="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
mcd () { mkdir -p "$1" && cd "$1"; } # mcd: Makes new Dir and jumps inside
alias UN='echo $USER' # UN: Echo Username
alias zshconfig="mate ~/.zshrc"
alias ohmyzsh="mate ~/.oh-my-zsh"
# nyg: shortcut to globally install pkgs with npm AND yarn
# ------------------------------------------------------------
nyg () { npm install --global "$1" && yarn global add "$1" ; }
# 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
# extract: Extract most known archives with one command
# ---------------------------------------------------------
extract () {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xjf $1 ;;
*.tar.gz) tar xzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar e $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xf $1 ;;
*.tbz2) tar xjf $1 ;;
*.tgz) tar xzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*) echo "'$1' cannot be extracted via extract()" ;;
esac
else
echo "'$1' is not a valid file"
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
# ---------------------------
# 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 "$@" ; }
# my_ps: List processes owned by my user:
# ------------------------------------------------------------
my_ps() { ps $@ -u $USER -o pid,%cpu,%mem,start,time,bsdtime,command ; }
hist() { history | grep "$@" ; }
# ---------------------------
# 6. NETWORKING
# ---------------------------
alias myip='curl ip.appspot.com' # myip: Public facing IP Address
alias netCons='lsof -i' # netCons: Show all open TCP/IP sockets
alias flushDNS='dscacheutil -flushcache' # flushDNS: Flush out the DNS Cache
alias lsock='sudo /usr/sbin/lsof -i -P' # lsock: Display open sockets
alias lsockU='sudo /usr/sbin/lsof -nP | grep UDP' # lsockU: Display only open UDP sockets
alias lsockT='sudo /usr/sbin/lsof -nP | grep TCP' # lsockT: Display only open TCP sockets
alias ipInfo0='ipconfig getpacket en0' # ipInfo0: Get info on connections for en0
alias ipInfo1='ipconfig getpacket en1' # ipInfo1: Get info on connections for en1
alias openPorts='sudo lsof -i | grep LISTEN' # openPorts: All listening connections
alias showBlocked='sudo ipfw list' # showBlocked: All ipfw rules inc/ blocked IPs
# ---------------------------------------
# 7. SYSTEMS OPERATIONS & INFORMATION
# ---------------------------------------
# cleanupDS: Recursively delete .DS_Store files
# -------------------------------------------------------------------
alias cleanupDS="find . -type f -name '*.DS_Store' -ls -delete"
# 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"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment