Created
September 20, 2018 15:37
-
-
Save hmorri32/c98497dbb802713662fbf0aa8ae33e25 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# vim:set ft=sh sw=2 sts=2: | |
[ -e "$SOURCE_DIR" ] || SOURCE_DIR="$HOME/hashrocket" | |
export SOURCE_DIR | |
# DEPRECATED: Use more generic SOURCE_DIR. HASHROCKET_DIR persists as a | |
# legacy artifact, and for 3rd-party scripts. | |
export HASHROCKET_DIR=$SOURCE_DIR | |
# Paths for prepending | |
for dir in /usr/local/bin "$HOME/bin" .git/safe/../../bin; do | |
case "$PATH:" in | |
*:"$dir":*) PATH="`echo "$PATH"|sed -e "s#:$dir##"`" ;; | |
esac | |
case "$dir" in | |
/*) [ ! -d "$dir" ] || PATH="$dir:$PATH" ;; | |
*) PATH="$dir:$PATH" ;; | |
esac | |
done | |
# Paths for appending | |
for dir in /usr/local/sbin /opt/local/sbin /usr/X11/bin; do | |
case ":$PATH:" in | |
*:"$dir":*) ;; | |
*) [ ! -d "$dir" ] || PATH="$PATH:$dir" ;; | |
esac | |
done | |
if command -v hub >/dev/null; then | |
git() { | |
command hub "$@" | |
} | |
fi | |
twiki () { | |
rake db:migrate && rake db:migrate:redo && rake db:test:prepare | |
} | |
alias sc='rails console' | |
alias ss='rails server' | |
alias sdbc='rails dbconsole -p' | |
alias ll='ls -l' | |
# git_prompt_info accepts 0 or 1 arguments (i.e., format string) | |
# returns text to add to bash PS1 prompt (includes branch name) | |
git_prompt_info () { | |
local g="$(command git rev-parse --git-dir 2>/dev/null)" | |
if [ -n "$g" ]; then | |
local r | |
local b | |
local d | |
local s | |
# Rebasing | |
if [ -d "$g/rebase-apply" ] ; then | |
if test -f "$g/rebase-apply/rebasing" ; then | |
r="|REBASE" | |
fi | |
b="$(command git symbolic-ref HEAD 2>/dev/null)" | |
# Interactive rebase | |
elif [ -f "$g/rebase-merge/interactive" ] ; then | |
r="|REBASE-i" | |
b="$(cat "$g/rebase-merge/head-name")" | |
# Merging | |
elif [ -f "$g/MERGE_HEAD" ] ; then | |
r="|MERGING" | |
b="$(command git symbolic-ref HEAD 2>/dev/null)" | |
else | |
if [ -f "$g/BISECT_LOG" ] ; then | |
r="|BISECTING" | |
fi | |
if ! b="$(command git symbolic-ref HEAD 2>/dev/null)" ; then | |
if ! b="$(command git describe --exact-match HEAD 2>/dev/null)" ; then | |
b="$(cut -c1-7 "$g/HEAD")..." | |
fi | |
fi | |
fi | |
# Dirty Branch | |
local newfile='?? ' | |
if [ -n "$ZSH_VERSION" ]; then | |
newfile='\?\? ' | |
fi | |
d='' | |
s=$(command git status --porcelain 2> /dev/null) | |
[[ $s =~ "$newfile" ]] && d+='+' | |
[[ $s =~ "M " ]] && d+='*' | |
[[ $s =~ "D " ]] && d+='-' | |
printf "${1-"(%s) "}" "${b##refs/heads/}$r$d" | |
fi | |
} | |
gcr() { | |
git checkout -b $1 origin/$1 | |
} | |
# git reset empty files | |
gref() { | |
command git --no-pager diff --cached --stat | command grep "|\s*0$" | awk '{system("command git reset " $1)}' | |
} | |
alias gap='git add -p' | |
alias gnap='git add -N --ignore-removal . && gap && gref' | |
alias glp='git log -p' | |
alias glg='git log --graph --oneline --decorate --color --all' | |
alias gb='git branch' | |
alias gc='git commit -v' | |
alias gca='git commit -a -v' | |
alias gcl='git clean -f -d' | |
alias gd='git diff' | |
alias gdc='git diff --cached' | |
alias gdh='git diff HEAD' | |
alias gl='git pull' | |
alias glod='git log --oneline --decorate' | |
alias gp='git push' | |
alias gpr='git pull --rebase' | |
alias gst='git status' | |
alias gr='git rebase' | |
alias grc='git rebase --continue' | |
alias gra='git rebase --abort' | |
alias gco='git checkout' | |
alias reset-authors='git commit --amend --reset-author -C HEAD' | |
alias vi='vim' | |
alias grim='git rebase -i master' | |
if [ "$(uname)" = Darwin -a "$(command -v vim)" = /usr/bin/vim ]; then | |
bettervim="/Applications/MacVim.app/Contents/MacOS/Vim" | |
[ -f "$bettervim" ] && alias vim="$bettervim" | |
[ -f "$HOME$bettervim" ] && alias vim="$HOME$bettervim" | |
fi | |
# RVM exectuble path for scripting, when available | |
if [[ -s "$HOME/.rvm/bin" ]] ; then export PATH="$PATH:$HOME/.rvm/bin" ; fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment