Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 270 lines (227 sloc) 7.31 KB
#
# aliases
#
alias editprofile='subl -w ~/.profile; . ~/.profile'
alias o='open .'
alias n='npm'
alias s='subl .'
alias m='subl .'
alias c='code .'
alias bj='bundle install -j8'
alias difflast='git diff HEAD^ HEAD > ~/Desktop/diff.diff'
alias gdiff='git diff --no-index --color'
alias g='amp git'
alias copy='pbcopy'
alias paste='pbpaste'
alias todos='git grep -in todo'
alias prettyjson='paste | json | copy'
alias uglyjs='paste | uglifyjs - | copy'
alias prettycss='paste | css-beautify -f - | copy'
# Autocomplete for 'g' alias as well
# complete -o default -o nospace -F git g
# for fast multiple terminal navigation to same dir
alias mark='pwd | pbcopy'
alias goo='cd `pbpaste`'
alias ql='qlmanage -p 2>/dev/null' # quicklook via terminal
umask 002 # prevent permissions problems
export JOBS=4 # for faster node building
export HISTCONTROL=ignoredups
export HISTSIZE=10000000
export HISTFILESIZE=10000000
export EDITOR='subl -w'
export EDITOR='subl -w'
export PAGER="less"
export CLICOLOR="yes"
export LSCOLORS=gxBxhxDxfxhxhxhxhxcxcx
export PROMPT_COLOR='1;1;40m'
# default prompt
# export PS1="\h:\W \u\$ "
parse_git_branch() {
$(which git) branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
# ~/dev/dotfiles(my-branch-name)§
export PS1="\w\[\e[0;33;49m\]\$(parse_git_branch)\[\e[0;0m\]\[\e[0;32m\]§\[\e[0m\] "
shopt -s checkwinsize cdspell
# for convenience of not typing branch names 24/7
gb() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'
}
# opens the github page for the current repo, written by @kurisuchan
function gh() {
open `git remote -v | grep hub | grep fetch | awk '{print $2}' | sed 's/git@/http:\/\//' | sed 's/com:/com\//' | sed 's/\.git//' | head -n1`
}
# for ghe, by david reiman
function ghe() {
git remote -v | awk '{ print $2 }' | sed 's/\.git//' | head -n 1 | xargs open
# open `git remote -v | node -pe "require('fs').readFileSync('/dev/stdin').toString().split('\t')[2].split(' ')[0].replace('.git', '')"`
}
function prstable() { # by David Trejo
# same as gh but without the "open"
githubUrl=`git remote -v | grep hub | grep fetch | awk '{print $2}' | sed 's/git@/http:\/\//' | sed 's/com:/com\//' | sed 's/\.git//' | head -n1`
# same as gb()
branch=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'`
open "$githubUrl/compare/stable...$branch?expand=1"
}
function prdevelop() { # by David Trejo
# same as gh but without the "open"
githubUrl=`git remote -v | grep hub | grep fetch | awk '{print $2}' | sed 's/git@/http:\/\//' | sed 's/com:/com\//' | sed 's/\.git//' | head -n1`
# same as gb()
branch=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'`
open "$githubUrl/compare/develop...$branch?expand=1"
}
# rm does move to trash
# via http://blog.vicshih.com/2008/04/move-to-trash-from-mac-command-line.html
function del() {
while [ -n "$1" ]; do
if [ ! -e "$1" ]; then
echo "'$1' not found; exiting"
return
fi
local file=`basename -- "$1"`
# Chop trailing '/' if there
file=${file%/}
local destination=''
if [ -e "$HOME/.Trash/$file" ]; then
# Extract file and extension
local ext=`expr "$file" : ".*\(\.[^\.]*\)$"`
local base=${file%$ext}
# Add a space between base and timestamp
test -n "$base" && base="$base "
destination="/$base`date +%H-%M-%S`_$RANDOM$ext"
fi
echo "Moving '$1' to '$HOME/.Trash$destination'"
\mv -i -- "$1" "$HOME/.Trash$destination" || return
shift
done
}
# only add to mac, in a fragile way.
if [[ "$OSTYPE" == 'darwin10.0' ]]; then
alias rm='del'
fi
# also lion
if [[ "$OSTYPE" == 'darwin11' ]]; then
alias rm='del'
fi
# also mountain lion
if [[ "$OSTYPE" == 'darwin12' ]]; then
alias rm='del'
fi
# also mavericks
if [[ "$OSTYPE" == 'darwin13' ]]; then
alias rm='del'
fi
# sierra
if [[ "$OSTYPE" == 'darwin16' ]]; then
alias rm='del'
fi
# Random configuration stuff
# add bash completion
# if [ -f /opt/local/etc/bash_completion ]; then
# . /opt/local/etc/bash_completion
# fi
alias pr='post-review'
alias pgstart='postgres -D /usr/local/var/postgres'
export MAVEN_OPTS="-server -Xms256m -Xmx512m"
alias zk='/Users/david/zookeeper-3.4.3/bin/zkServer.sh'
export DEV_DIR="$HOME/Dropbox/dev"
alias dev="cd $DEV_DIR"
function d() {
cd $DEV_DIR/"$1"
}
alias class='cd ~/Dropbox/classes'
alias desktop='$HOME/Desktop'
alias ..='cd ..'
alias ...='cd ../../'
# raise the number of files a process is allowed to have open.
ulimit -S -n 5000
#
# pull in private things or things only applicable to this machine
#
source ~/.private
#
# if stuff snuck into ~/.bashrc, source it
#
# source ~/.bashrc
# add git extensions/scripts to path
export PATH=$PATH:$HOME/bin
# add mactex scripts
export PATH=$PATH:/usr/texbin
alias sl='ls -p'
alias ls='ls -p'
# fix problem with tmux
export TERM=xterm-color
alias logs='heroku logs -n 10000 --tail'
##
# Your previous /Users/david/.profile file was backed up as /Users/david/.profile.macports-saved_2012-08-09_at_12:28:22
##
# MacPorts Installer addition on 2012-08-09_at_12:28:22: adding an appropriate PATH variable for use with MacPorts.
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
# Finished adapting your PATH environment variable for use with MacPorts.
# {{{
# Node Completion - Auto-generated, do not touch.
shopt -s progcomp
for f in $(command ls ~/.node-completion); do
f="$HOME/.node-completion/$f"
test -f "$f" && . "$f"
done
# }}}
# makes it easy to find the main js file for any node package:
# nresolve mypackage
nresolve () {
node -p 'require.resolve("'$1'")'
}
#
# amp aliases! YEEE
#
#
# give me variable saving!
alias gs='amp -p "...(.*)$" git status -s'
alias gbr='amp -p " ? (?:remotes\\/)?(?:origin\\/)?(.*)$" git branch --sort=-committerdate' # supports -a, -r flags
alias l='CLICOLOR_FORCE=1 amp -p "(.*)" ls -1'
alias find='amp -p "(.*)" find'
alias gdiffstat='amp -p " ((?:\\/[\\w\\.\\-]+)+)" git diff --stat'
# give me variable expansion!
alias subl='amp subl'
alias code='amp code'
alias ga='amp git add'
alias gap='amp git add -p'
alias grm='amp git rm'
alias gmv='amp git mv'
alias gco='amp git checkout'
alias gd='amp git diff'
alias gdh='amp git diff --staged'
alias gds='amp git diff --staged'
alias gunstage='amp git unstage'
alias gblame='amp git blame'
alias gup='amp git up' # my rebase helper script, see dtrejo/dotfiles/bin/git-up
alias gf='git fetch'
alias npx='amp npx'
alias x='amp npx'
alias cat='amp cat'
alias less='amp less'
alias gc='git commit'
alias gp='amp git push'
alias gpu='amp git push -u origin `gb`'
alias mocha='amp mocha'
alias phpfix='amp /usr/local/Cellar/php-cs-fixer/2.7.1/php-cs-fixer fix --rules=@PSR2'
# less typing
alias gamend='git amend'
alias gci="git commit"
alias guncommit='git uncommit'
# via https://stackoverflow.com/a/19135644
alias gitbranchauthors="git for-each-ref --format='%(committerdate) %09 %(authorname) %09 %(refname)' | sort -k5n -k2M -k3n -k4n"
function newbranchcommit() {
git checkout -b "${$1// /-}" && git commit --allow-empty -m "$1"
}
function signwtf() {
export NUMBER=$1
export URL="https://github.com/brianleroux/wtfjs/pull/$NUMBER.patch"
curl $URL | git am --signoff
}
export GOPATH=$HOME/go
export PATH=$PATH:$GOPATH/bin
# export PATH="$HOME/.rbenv/bin:$PATH"
# if [[ $(which rbenv) ]]; then
# eval "$(rbenv init -)"
# fi
alias lock="open /System/Library/Frameworks/ScreenSaver.framework/Versions/A/Resources/ScreenSaverEngine.app"