Skip to content

Instantly share code, notes, and snippets.

@richy486
Last active November 9, 2020 10:15
Show Gist options
  • Save richy486/2279902 to your computer and use it in GitHub Desktop.
Save richy486/2279902 to your computer and use it in GitHub Desktop.
bash profile
# BASH PROFILE!!
# reload without closing terminal window with $ source ~/.bash_profile
# Alias'
export LSCOLORS="ExGxBxDxCxEgEdxbxgxcxd"
alias ls="ls -G -a -l"
alias glog="git log --graph --date-order --date=relative --color=always --oneline"
alias gstat="git status -s"
alias mm?="git branch --merged master"
alias cdd="rm -rf ~/Library/Developer/Xcode/DerivedData"
alias cdp="git checkout develop; git pull;"
alias ulc="git reset HEAD~"
# git config --global color.status auto
export PATH=~/scripts:$PATH
export PATH=/Library/Developer/Toolchains/swift-latest.xctoolchain/usr/bin:"${PATH}"
export SWIFTENV_ROOT="$HOME/.swiftenv"
export PATH="$SWIFTENV_ROOT/bin:$PATH"
eval "$(swiftenv init -)"
# Xcode
export xcode7path='/Applications/Xcode7.app'
export xcode8path='/Applications/Xcode8.app'
export xcode9path='/Applications/Xcode9.app'
export xcode10path='/Applications/Xcode_10.app'
export xcode10betapath='/Applications/Xcode_10_beta.app'
xcselect() {
sudo xcode-select -s "$1"/Contents/Developer
ln -s "$1" /Applications/Xcode.app
echo "Selected Xcode: ${1}"
}
xclist() {
ls -1 /Applications/ | sed 's#.*/##' | grep "Xcode"
}
xc() {
sudo xcode-select -s /Applications/"$1"/Contents/Developer
echo "Selected Xcode: ${1}"
}
alias xcstable="xcselect ${xcode10path}"
alias xcbeta="xcselect ${xcode10betapath}"
alias xcprint="xcode-select -p"
alias swiftGitignore="curl https://raw.githubusercontent.com/github/gitignore/master/Swift.gitignore > .gitignore"
# Cocoapods
alias repod="rm -rf \"${HOME}/Library/Caches/CocoaPods\"; rm -rf \"`pwd`/Pods/\"; pod update"
#fastlane
export PATH="$HOME/.fastlane/bin:$PATH"
#android
export PATH=~/Library/Android/sdk/tools:$PATH
export PATH=$ANDROID_HOME/emulator:"${PATH}"
export ANDROID_HOME=~/Library/Android/sdk
# --------- Git -----------
# get current branch in git repo
function parse_git_branch() {
BRANCH=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'`
if [ ! "${BRANCH}" == "" ]
then
STAT=`parse_git_dirty`
echo "[${BRANCH}${STAT}]"
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
}
# --------- Prompt -----------
export PS1="\[\e[34m\]\u\[\e[m\]:\[\e[32m\]\w\[\e[m\] \[\e[33m\]\`parse_git_branch\`\[\e[m\]$ "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment