Skip to content

Instantly share code, notes, and snippets.

@emelent
Last active September 9, 2019 20:25
Show Gist options
  • Save emelent/3223fa4830c4997756f55a272f581573 to your computer and use it in GitHub Desktop.
Save emelent/3223fa4830c4997756f55a272f581573 to your computer and use it in GitHub Desktop.
# Tell ls to be colourful
export CLICOLOR=1
# Tell grep to highlight matches
export GREP_OPTIONS='--color=auto'
# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.
export PATH="$PATH:$HOME/.rvm/bin:$HOME/bin:$HOME/bin/apache-maven-3.5.0/bin:$HOME/development/flutter/bin:$HOME/bin/apache-maven-3.6.1/bin:$HOME/bin/gatling-3.1.2/bin"
export GOPATH=$HOME/go
export ANDROID_HOME=$HOME/Library/Android/sdk
export ANDROID_PLATFORM_TOOLS=$ANDROID_HOME/platform-tools
export ANDROID_TOOLS=$ANDROID_HOME/tools
export GOPROJ=$GOPATH/src/github.com/emelent
export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk-11.jdk/Contents/Home"
export PATH=$PATH:$GOPATH/bin:$ANDROID_TOOLS:$ANDROID_TOOLS/bin/:$ANDROID_PLATFORM_TOOLS:~/flutter/flutter/bin
# Set locale for mac
export LC_ALL=en_GB.UTF-8
function nonzero_return() {
RETVAL=$?
[ $RETVAL -ne 0 ] && echo -ne "${red}✗${none} "
#echo -ne "${red}"
}
gold="\033[33m"
blue="\033[34m"
cyan="\033[36m"
red="\033[31m"
darkgrey="\033[90m"
none="\033[m"
function parse_git_branch() {
BRANCH=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'`
if [ ! "${BRANCH}" == "" ]
then
STAT=`parse_git_dirty`
[ "$STAT" != "" ] && echo -ne $red || echo -ne $darkgrey
echo -e "($BRANCH)$none"
else
echo ""
fi
}
# get current status of git repo
function parse_git_dirty {
status=`git status 2>&1 | tee`
dirty=`echo -n "${status}" 2> /dev/null | grep "modified:" &> /dev/null; echo "$?"`
untracked=`echo -n "${status}" 2> /dev/null | grep "Untracked files" &> /dev/null; echo "$?"`
ahead=`echo -n "${status}" 2> /dev/null | grep "Your branch is ahead of" &> /dev/null; echo "$?"`
newfile=`echo -n "${status}" 2> /dev/null | grep "new file:" &> /dev/null; echo "$?"`
renamed=`echo -n "${status}" 2> /dev/null | grep "renamed:" &> /dev/null; echo "$?"`
deleted=`echo -n "${status}" 2> /dev/null | grep "deleted:" &> /dev/null; echo "$?"`
bits=''
if [ "${renamed}" == "0" ]; then
bits=">${bits}"
fi
if [ "${ahead}" == "0" ]; then
bits="*${bits}"
fi
if [ "${newfile}" == "0" ]; then
bits="+${bits}"
fi
if [ "${untracked}" == "0" ]; then
bits="?${bits}"
fi
if [ "${deleted}" == "0" ]; then
bits="x${bits}"
fi
if [ "${dirty}" == "0" ]; then
bits="!${bits}"
fi
if [ ! "${bits}" == "" ]; then
echo " ${bits}"
else
echo ""
fi
}
export PS1="\w \`parse_git_branch\`\n→ "
function prompt_command {
nonzero_return
}
export PROMPT_COMMAND=prompt_command
export IP_J4="192.168.43.1"
alias a2c="aria2c -x 16 -s 16"
alias y2c="youtube-dl --external-downloader aria2c\
--external-downloader-args \"-x 16 -s 16\" --no-check-certificate\
-o \"%(uploader)s.%(playlist_title)s_%(autonumber)03d.%(alt_title)s.%(display_id)s.%(id)s.%(width)sx%(height)s.%(ext)s\""
alias pj="python -m json.tool"
alias py="python3"
alias py2="python2"
alias pfind="ps -e | grep"
alias hfind="history | grep"
alias p3="ping -c 3"
alias p3g="ping -c 3 www.google.com"
alias netear="netstat -ap tcp | grep -i 'listen'"
alias put="http put"
alias get="http get"
alias post="http post"
alias delete="http delete"
function getIP {
ifconfig en0 inet | grep inet | awk '{print $2}'
}
function adbWifi {
adb tcpip 5555
adb connect $1:5555
}
function loc {
find . -name "$1" | xargs wc -l | grep total
}
eval `keychain --eval --quiet id_rsa`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment