Skip to content

Instantly share code, notes, and snippets.

@rikkrome
Last active September 9, 2019 02:13
Show Gist options
  • Save rikkrome/25ed3074596387f9a1f6be101c744995 to your computer and use it in GitHub Desktop.
Save rikkrome/25ed3074596387f9a1f6be101c744995 to your computer and use it in GitHub Desktop.
# -------------------------------
# ENVIRONMENT CONFIGURATION
# -------------------------------
# Change Prompt
# ------------------------------------------------------------
# PS1 settings
# ---------------------------------------------------
# colors
export COLOR_NC='\e[0m' # No Color
export COLOR_WHITE='\e[1;37m'
export COLOR_BLACK='\e[0;30m'
export COLOR_BLUE='\e[0;34m'
export COLOR_LIGHT_BLUE='\e[1;34m'
export COLOR_GREEN='\e[0;32m'
export COLOR_LIGHT_GREEN='\e[1;32m'
export COLOR_CYAN='\e[0;36m'
export COLOR_LIGHT_CYAN='\e[1;36m'
export COLOR_RED='\e[0;31m'
export COLOR_LIGHT_RED='\e[1;31m'
export COLOR_PURPLE='\e[0;35m'
export COLOR_LIGHT_PURPLE='\e[1;35m'
export COLOR_BROWN='\e[0;33m'
export COLOR_YELLOW='\e[1;33m'
export COLOR_GRAY='\e[0;30m'
export COLOR_LIGHT_GRAY='\e[0;37m'
bold=$(tput bold)
normal=$(tput sgr0)
# ------
# Git branch in prompt.
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
timeAlignRight(){
printf "%*s" $COLUMNS "[$(date +%I:%M:%S)]"
}
logHeaderLines(){
lines=""
dash="-"
num=$COLUMNS-5
for (( c=1; c<=$num; c++ ))
do
lines=$lines$dash
done
printf "⎥%s" "$lines"
}
arrows="\[${COLOR_PURPLE}\]${bold}>${normal}\[${COLOR_RED}\]${bold}>${normal}\[${COLOR_LIGHT_GREEN}\]${bold}>${normal}"
logVLine="\[${COLOR_GREEN}\]${bold}⎥${normal}"
logTime="\[${COLOR_PURPLE}\]${bold}\$(timeAlignRight)${normal}"
logLine="\[${COLOR_GREEN}\]${bold}\$(logHeaderLines)${normal}"
logPath="\[${COLOR_GREEN}\]\w"
logUser="\[${COLOR_CYAN}\](\u)"
logGit="\[${COLOR_LIGHT_GREEN}\]git\$(parse_git_branch)\[\033[00m\]"
logPromt="${arrows} \[${COLOR_NC}\]"
printRow1="${logTime}\n"
printRow2="${logLine}\n"
printRow3="${logVLine} ${logUser} ${logPath}\n"
printRow4="${logVLine} ${logGit}\n"
printRow5="${logVLine} ${logPromt}"
export PS1="${printRow1}${printRow2}${printRow3}${printRow4}${printRow5}"
export PS2="| =>"
# end of PS1 ---------------------------------------------------
# Set Paths
# ------------------------------------------------------------
export PATH="$PATH:/usr/local/bin/"
export PATH="/usr/local/git/bin:/sw/bin/:/usr/local/bin:/usr/local/:/usr/local/sbin:/usr/local/mysql/bin:$PATH"
# ANDROID
export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools
export PATH=$PATH:$ANDROID_HOME/emulator
# Set Default Editor (change 'Nano' to the editor of your choice)
# ------------------------------------------------------------
export EDITOR=/usr/bin/vim
# Set default blocksize for ls, df, du
# ------------------------------------------------------------
export BLOCKSIZE=1k
# -----------------------------
# ALIAS
# -----------------------------
alias cp='cp -iv' # Preferred 'cp' implementation
alias mv='mv -iv' # Preferred 'mv' implementation
alias mkdir='mkdir -pv' # Preferred 'mkdir' implementation
alias ll='ls -FGlAhp' # Preferred 'ls' implementation
alias less='less -FSRXc' # Preferred 'less' implementation
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 k='clear' # k: Clear terminal display
alias which='type -all' # which: Find executables
alias path='echo -e ${PATH//:/\\n}' # path: Echo all executable Paths
alias show_opt='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
# ---------------------------
# Git
# ---------------------------
alias gpo='git pull origin'
alias gpuo='git push -u origin'
alias gb='git branch -vv'
alias gd='git branch -d'
alias gD='git branch -D'
alias gsl='git stash list'
alias gs='git status'
alias gc='git checkout'
alias gf='git fetch'
# ---------------------------
# React-native
# ---------------------------
alias rrhelp='cat ~/rrcli/rrhelp.md'
alias rnstart='react-native start'
alias rnstartrc='react-native start -- --reset-cache'
alias rnios='react-native run-ios'
alias rniosx='react-native run-ios --simulator="iPhone X"'
alias rnios5='react-native run-ios --simulator="iPhone 5s"'
alias rnand='react-native run-android'
# ---------------------------
# 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment