Skip to content

Instantly share code, notes, and snippets.

@beenhere4hours
Last active October 23, 2019 15:24
Show Gist options
  • Save beenhere4hours/f2437998d0d41d39fe43 to your computer and use it in GitHub Desktop.
Save beenhere4hours/f2437998d0d41d39fe43 to your computer and use it in GitHub Desktop.
SGP - Mac OSX 10.9.5 - work machine bash profile for reference
# ---------------------------------------------------------- alias
# list long
alias ll='ls -lah'
# go to code dir
alias code='cd ~/code'
# clear screen
alias cl='clear'
# dos tree command
alias tree='find . -print | sed -e '\''s;[^/]*/;|__;g;s;__|; |;g'\'' | more'
# display last commit on each branch
alias glist='for ref in $(git for-each-ref --sort=-committerdate --format="%(refname)" refs/heads/ refs/remotes ); do git log -n1 $ref --pretty=format:"%Cgreen%cr%Creset %C(yellow)%d%Creset %C(bold blue)<%an>%Creset%n" | cat ; done | awk '"'! a["'$0'"]++'"
# removed merged branches from remote
alias gcleanse="git branch -r --merged | grep -v master | grep -v dev | grep origin | sed 's/origin\//:/' | xargs -n 1 git push origin"
# display impact on branch
alias grank='git log --author="Daniel Masi" --pretty=tformat: --numstat | awk '\''{ add += $1 ; subs += $2 ; loc += $1 - $2 } END { printf "added lines: %s removed lines: %s total lines: %s\n",add,subs,loc }'\'' -'
alias mysql=/usr/local/mysql/bin/mysql
alias mysqladmin=/usr/local/mysql/bin/mysqladmin
# ---------------------------------------------------------- git
export PATH="$PATH:/usr/local/git/bin/"
# added for git branch tab completion
source /usr/local/git/contrib/completion/git-prompt.sh
source /usr/local/git/contrib/completion/git-completion.bash
GIT_PS1_SHOWUPSTREAM="auto"
GIT_PS1_SHOWCOLORHINTS="yes"
# ---------------------------------------------------------- java
# http://www.jayway.com/2014/01/15/how-to-switch-jdk-version-on-mac-os-x-maverick/
function setjdk() {
if [ $# -ne 0 ]; then
removeFromPath '/System/Library/Frameworks/JavaVM.framework/Home/bin'
if [ -n "${JAVA_HOME+x}" ]; then
removeFromPath $JAVA_HOME
fi
export JAVA_HOME=`/usr/libexec/java_home -v $@`
export PATH=$JAVA_HOME/bin:$PATH
fi
}
function removeFromPath() {
export PATH=$(echo $PATH | sed -E -e "s;:$1;;" -e "s;$1:?;;")
}
# ---------------------------------------------------------- history
# custom history size
HISTSIZE=1000
# custom history file size
HISTFILESIZE=10000
# erasedups causes all previous lines matching the current line to be removed
HISTCONTROL=ignoredups:erasedups
# store commands that span multiple lines as one line in history
shopt -s histappend
# history -n read from .bash_history commands saved from any other terminal
# history -w save history to file and erase dups
# history -c prevent trashing the history buffer after each command
# history -r restore the history buffer from file making it shareable across terminal sessions
PROMPT_COMMAND="history -n; history -w; history -c; history -r; $PROMPT_COMMAND"
# ---------------------------------------------------------- exports
export PROMPT_COMMAND='__git_ps1 "\u@\h:\W" "\\\$ ";'
# added for node nvm / node version manager
source ~/.nvm/nvm.sh
# grep with color output
export GREP_OPTIONS='--color=auto'
export JAVA_HOME=$(/usr/libexec/java_home)
# android tools
export PATH="$PATH:/Users/dmasi/android-sdk-macosx:/Users/dmasi/android-sdk-macosx/platform-tools:/Users/dmasi/android-sdk-macosx/tools"
# laravel
export PATH="$PATH:/Users/dmasi/.composer/vendor/bin/"
# connect to filer/public
function gomobile() {
if [ `mount | grep "on /Volumes/Mobile"` ]; then
cd /Volumes/Mobile/dept-IT/Mobile/
else
mount_smbfs //dan.masi@safe-prop.isi00-2317.conas.local/Departments /Volumes/Mobile
cd /Volumes/Mobile/dept-IT/Mobile/
fi
}
export -f gomobile
export ANDROID_SDK="/Users/dmasi/android-sdk-macosx"
export ANDROID_NDK="/Users/dmasi/android-ndk-r9c"
export PATH="$PATH:$ANDROID_SDK/tools:$ANDROID_SDK/platform-tools:$ANDROID_NDK"
function gcommit() {
## Verify we are in a git repo
if ! git rev-parse --git-dir > /dev/null 2>&1; then
echo "The path '$(pwd)' is not a git repository"
# popd > /dev/null
return 1
fi
### Branch Name
local brName=$(git rev-parse --abbrev-ref HEAD)
### Break-Up Name
IFS='-_' read -r -a brNameArray <<< "$brName"
local segSize="${#brNameArray[@]}"
local fName="[${brNameArray[0]}-${brNameArray[1]}]"
echo -n "Enter Comment Msg: $fName "
read cMsg
git commit -m "$fName $cMsg"
}
# ----- MacPorts -----
. /sw/bin/init.sh
export PATH="$PATH:/opt/local/bin:/opt/local/sbin:/sw/bin:/sw/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/Users/dmasi/bin/:/Users/dmasi/.composer/vendor/bin/:/usr/local/mysql/bin"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment