Skip to content

Instantly share code, notes, and snippets.

@tsiege
Last active March 20, 2020 20:16
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save tsiege/455d7458f2a3cbb8c4f1 to your computer and use it in GitHub Desktop.
Save tsiege/455d7458f2a3cbb8c4f1 to your computer and use it in GitHub Desktop.
Bash Profile
# prompt and env config stuff
#============================
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) == "nothing to commit, working directory clean" ]] && echo " ✔"
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit, working directory clean" ]] && echo " ✘"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/ (\1$(parse_git_dirty))/"
}
function prompt {
local RED="\[\033[0;31m\]"
local LIGHT_RED="\[\033[1;31m\]"
local CHAR="⏣ ⌬ "
export PS1="\[\e]2;\u@\h\a[\[\e[37;44;1m\]\t\[\e[0m\]] \[\e[32m\]\W\[\e[0m\]$RED\$(parse_git_branch)\n\[\e[0;31m\]$CHAR \[\e[0m\]"
PS2='> '
PS4='+ '
}
prompt
# node path
export NODE_PATH="/usr/local/lib/node_modules:$NODE_PATH"
# gitconfig stuff
export GIT_MERGE_AUTOEDIT='no'
# editor settings
export VISUAL="subl -w"
export SVN_EDITOR="subl -w"
export GIT_EDITOR="subl -w"
export EDITOR="subl -w"
# homebrew path
export USR_PATHS="/usr/local:/usr/local/bin:/usr/local/sbin:/usr/bin"
#final path
export PATH="$USR_PATHS:$PATH"
# Helpful Functions
# =====================
function desktop {
cd /Users/$USER/Desktop/$@
}
# A function to easily grep for a matching process
# USE: psg postgres
function psg {
FIRST=`echo $1 | sed -e 's/^\(.\).*/\1/'`
REST=`echo $1 | sed -e 's/^.\(.*\)/\1/'`
ps aux | grep "[$FIRST]$REST"
}
# A function to extract correctly any archive based on extension
# USE: extract imazip.zip
# extract imatar.tar
function extract () {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xjf $1 ;;
*.tar.gz) tar xzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) rar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xf $1 ;;
*.tbz2) tar xjf $1 ;;
*.tgz) tar xzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*) echo "'$1' cannot be extracted via extract()" ;;
esac
else
echo "'$1' is not a valid file"
fi
}
# Aliases
# =====================
# LS
alias l='ls -lah'
# Git
alias gaa="git add -A"
alias gst="git status"
alias gl="git pull"
alias glr="git pull --rebase"
alias gp="git push"
alias gd="git diff | mate"
alias gc="git commit -v"
alias gca="git commit -v -a"
alias gcm="git commit -m"
alias gb="git branch"
alias gba="git branch -a"
alias gco="git checkout"
alias gcom="git checkout master"
alias gcos="git checkout solution"
# Final Configurations and Plugins
# =====================
# Git Bash Completion
if [ -f `brew --prefix`/etc/bash_completion ]; then
. `brew --prefix`/etc/bash_completion
fi
if [ -f ~/.git-completion.bash ]; then
. ~/.git-completion.bash
fi
# Sourcing RVM (MUST BE LAST IN PROFILE)
[[ -s "/Users/$USER/.rvm/scripts/rvm" ]] && source "/Users/$USER/.rvm/scripts/rvm"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment