Alias tweaks

This commit is contained in:
Michael Campagnaro 2013-07-07 17:30:11 -04:00
parent cf3eea13fb
commit 16f867a2bb
6 changed files with 173 additions and 184 deletions

View File

@ -28,45 +28,3 @@
frag = magenta
old = red
new = green
[alias]
b = branch
h = !git head
l = !git ll -25
p = push
r = reset
s = stash
x = reset --hard
sl = stash list
sp = stash pop
sd = stash drop
sa = stash apply
st = status
ci = commit
cp = cherry-pick
co = checkout
d = diff
dc = diff --cached
ds = diff --staged
dw = diff --color-words
ae = commit --amend
aa = add --all
head = !git l -1
hp = "!source ~/.githelpers && show_git_head"
re = remote
ra = !git r --all
ff = merge --ff-only
pff = pull --ff-only
noff = merge --no-ff
theirs = merge -Xtheirs
la = !git ll --all
ll = "!source ~/.githelpers && pretty_git_log"
div = divergence
gn = goodness
gnc = goodness --cached
fa = fetch --all
pom = push origin master
ds = diff --stat=160,120
dh1 = diff HEAD~1
snapshot = !git stash save "snapshot: $(date)" && git stash apply "stash@{0}"
ours = "!f() { git checkout --ours $@ && git add $@; }; f"
theirs = "!f() { git checkout --theirs $@ && git add $@; }; f"

View File

@ -1,125 +1,110 @@
# Handle the fact that this file will be used with multiple OSs
platform=`uname`
if [[ $platform == 'Linux' ]]; then
alias a='ls -lrth --color'
alias l='ls -l --color'
alias ll='ls -lrth --color'
elif [[ $platform == 'Darwin' ]]; then
alias a='ls -lrthG'
alias l='ls -laG'
alias ll='ls -lG'
fi
alias amend="git commit --amend"
alias asu="cd ~/code/rails/activesupport"
alias c='cd'
alias cd-='cd -'
alias ..='cd ../'
alias ...='cd ../..'
alias cd..='cd ..'
alias cd...='cd ../..'
alias cd....='cd ../../..'
alias cd.....='cd ../../../..'
alias cd/='cd /'
alias ls='ls -G'
alias aliases='vim ~/.dotfiles/zsh/aliases'
alias b='ssh -t ben@benorenstein.com screen -rd irc'
alias bake='bundle exec rake'
alias be='bundle exec'
alias ben='ssh ben@benorenstein.com'
alias bi='bundle install'
alias be='bundle exec'
alias bo='cd ~/code/boardwalk'
alias beg='bundle exec guard'
alias bu='bundle update'
alias bunbang='bundle install && !!'
alias c='cd'
alias cls=clear
alias code='cd ~/code'
alias codereview='vim ~/Dropbox/notes/code-review-checklist.txt'
alias d='cd ~/.dotfiles'
alias dbprep='rdm && rdtp'
alias di='cd ~/code/discourse'
alias dr='cd ~/Dropbox'
alias drop='cd ~/Dropbox'
alias fs='foreman start'
alias -g G='| grep'
alias gad='git add .'
alias gadu='git add -u .'
alias gbc='gdc'
alias gca='git commit -a'
alias gcaa='git commit -a --amend -C HEAD'
alias duh='du -csh'
# Git
alias ammend='amend'
alias amend='git commit --amend'
alias gaa='echo "Use ga!" && git add --all'
alias ga='git add --all'
alias gae='echo "Use amend!" && git commit --amend' # Remove when not needed
alias gau='git add --update'
alias gb='git branch'
alias gc='git commit'
alias gci='echo "Use gc!" && git commit' # Remove when no longer needed
alias gcl='git clone'
alias gcm="git commit -m"
alias gco='git checkout'
alias gcp='git cherry-pick'
alias gd='git diff'
alias gdc='git diff --cached'
alias gdm='git diff master'
alias get='sudo apt-get install'
alias gg='git lg'
alias gpush='echo "Use gp!" && git push'
alias gds='git diff --stat=160,120'
alias gdw='git diff --color-words'
alias gf='git fetch'
alias gh="source ~/.githelpers && show_git_head"
alias gl="source ~/.githelpers && pretty_git_log"
alias gll='git ll -25'
alias gla='git ll --all'
alias gmff='git merge -ff-only'
alias gmtheirs='git merge -Xtheirs'
alias gp='git push'
alias gpf='git push -f'
alias gpff='git pull --ff-only'
alias gpom='git push origin master'
alias gpr='git pull --rebase'
alias gr='git reset'
alias grc='git rebase --continue'
alias grake='rspec --drb spec/ && cucumber --drb features/'
alias gurad='guard'
alias h='sync'
alias he='cd ~/code/hacker-engine'
alias herkou='heroku'
alias hpush='git push heroku'
alias gre='git remote'
alias gsnapshot='git stash save "snapshot: $(date)" && git stash apply "stash@{0}"'
alias gst='git status'
alias gs='git stash'
alias gsa='git stash apply'
alias gsd='git stash drop'
alias gsl='git stash list'
alias gsp='git stash pop'
alias gx='git reset --hard'
alias history='fc -l 1'
alias irb='irb --readline -r irb/completion'
alias journal='vim ~/Dropbox/docs/journal/2011.txt'
alias killruby='killall -9 ruby'
alias killrudy='killall -9 ruby'
alias -g M='| more'
alias mastre='master'
alias newscreen="screen -S foo"
#alias l='cd ~/code/learn'
alias -g L='| less'
alias pc='production-console'
alias parallel='rdtp && rake parallel:prepare test:parallel_with_specs'
alias patch='git format-patch HEAD^ --stdout > patch.diff'
alias podcast='vim ~/Dropbox/work/thoughtbot/notes/podcast.txt'
alias prepdb='dbprep'
alias r='cd ~/code/refactoring-good-to-great'
alias remore='!! | more'
alias reguard='killall -9 ruby ; guard'
alias rerake='!! && rake'
alias restart_apache="sudo /etc/init.d/apache2 restart"
alias restart_postgres="stoppostgres && startpostgres"
alias retag='ctags -R --exclude=.svn --exclude=.git --exclude=log --exclude=tmp *'
alias retagwithcoffee='ctags -R --exclude=.svn --exclude=.git --exclude=log --exclude=tmp * && coffeetags -R -f >> tags'
alias repush="gpr && git push"
alias review="git diff master"
alias r='rails'
alias rc='rails console'
alias remigrate='rake db:migrate && rake db:migrate:redo && rake db:schema:dump && rake db:test:prepare'
alias rdm="be rake db:migrate"
alias rdtp="be rake db:test:prepare"
alias rs='bundle install && rails server -p 3000'
alias safepush='git pull --rebase && bundle install && rdm && rake && git push'
alias sfh='cd ~/code/speaking-for-hackers-book'
alias shpush='rake && hpush'
alias sc='staging-console'
alias so='source ~/.dotfiles/zsh/aliases'
alias sp='safepush'
alias speaking='cd ~/Dropbox/speaking'
alias ss='ruby app.rb'
alias startpostgres='pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start'
alias startredis='redis-server /usr/local/etc/redis.conf &'
alias stoppostgres='pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log stop'
alias staging='git push heroku-staging master'
alias sync='git add -u . && git commit -m "Minor changes. Commit message skipped." && repush'
alias reload='source ~/.zshrc'
alias tail-logs='heroku logs -t'
alias track='git checkout -t'
alias warmup='vim ~/Dropbox/barbershop/warmups/ideas.txt'
alias worknotes='vim ~/Dropbox/work/thoughtbot/notes'
alias u='cd ..'
alias v='vim'
alias vi='vim'
alias vu='cd ~/code/vim-university'
alias y='cd ~/code/ybuy'
alias z='zeus'
alias zs='zeus start'
alias vimrc='vim ~/.vimrc'
alias zsh='vim ~/.zshrc'
# Notes
alias todo='vim ~/Dropbox/notes/life-todo'
alias wtodo='vim ~/Dropbox/notes/work-todo'
alias sharp='vim ~/Dropbox/notes/sharpening-notes'
# Projects
alias projects='cd ~/code/projects'
alias perks='cd ~/code/work/src/campusperks'
alias work='cd ~/code/work'
alias learn='cd ~/code/learning-area'
alias dot='cd ~/code/projects/dotfiles'
# Heroku staging
alias staging-console='heroku run console --remote staging'
alias staging-tail='heroku logs --tail --remote staging'
alias staging-console='heroku run console --app campusperks-staging'
alias staging-tail='heroku logs --tail --app campusperks-staging'
# Heroku production
alias production-console='heroku run console --remote production'
alias production-tail='heroku logs --tail --remote production'
# # Heroku databases
alias db-pull-staging='heroku db:pull --remote staging --confirm `basename $PWD`-staging'
alias db-pull-production='heroku db:pull --remote production --confirm `basename $PWD`-production'
alias db-copy-production-to-staging='heroku pgbackups:restore DATABASE `heroku pgbackups:url --remote production` --remote staging --confirm `basename $PWD`-staging'
alias db-backup-production='heroku pgbackups:capture --remote production'
alias db-backups='heroku pgbackups --remote production'
alias levelup-get-production='curl -o ~/Downloads/latest.dump `heroku pgbackups:url --app levelup-production`'
alias levelup-db-fix='killruby ; rake db:drop:all db:create:all ; pg_restore --verbose --clean --no-acl --no-owner -d levelup_development ~/Downloads/latest.dump -j 8 ; prepdb && rake levelup:dev:create_admin && rails runner CreditCard.delete_all'
alias production-console='heroku run console --app campusperks'
alias production-tail='heroku logs --tail --app campusperks'

View File

@ -1,3 +1,11 @@
function activate_virtualenv() {
if [ -f env/bin/activate ]; then . env/bin/activate;
elif [ -f ../env/bin/activate ]; then . ../env/bin/activate;
elif [ -f ../../env/bin/activate ]; then . ../../env/bin/activate;
elif [ -f ../../../env/bin/activate ]; then . ../../../env/bin/activate;
fi
}
function git-new-remote-tracking {
git checkout -b $1 && git push -u origin $1
}

72
zsh/lib/completion.zsh Normal file
View File

@ -0,0 +1,72 @@
# fixme - the load process here seems a bit bizarre
unsetopt menu_complete # do not autoselect the first completion entry
unsetopt flowcontrol
setopt auto_menu # show completion menu on succesive tab press
setopt complete_in_word
setopt always_to_end
WORDCHARS=''
zmodload -i zsh/complist
## case-insensitive (all),partial-word and then substring completion
if [ "x$CASE_SENSITIVE" = "xtrue" ]; then
zstyle ':completion:*' matcher-list 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
unset CASE_SENSITIVE
else
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
fi
zstyle ':completion:*' list-colors ''
# should this be in keybindings?
bindkey -M menuselect '^o' accept-and-infer-next-history
zstyle ':completion:*:*:*:*:*' menu select
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01'
zstyle ':completion:*:*:*:*:processes' command "ps -u `whoami` -o pid,user,comm -w -w"
# disable named-directories autocompletion
zstyle ':completion:*:cd:*' tag-order local-directories directory-stack path-directories
cdpath=(.)
# use /etc/hosts and known_hosts for hostname completion
[ -r /etc/ssh/ssh_known_hosts ] && _global_ssh_hosts=(${${${${(f)"$(</etc/ssh/ssh_known_hosts)"}:#[\|]*}%%\ *}%%,*}) || _ssh_hosts=()
[ -r ~/.ssh/known_hosts ] && _ssh_hosts=(${${${${(f)"$(<$HOME/.ssh/known_hosts)"}:#[\|]*}%%\ *}%%,*}) || _ssh_hosts=()
[ -r /etc/hosts ] && : ${(A)_etc_hosts:=${(s: :)${(ps:\t:)${${(f)~~"$(</etc/hosts)"}%%\#*}##[:blank:]#[^[:blank:]]#}}} || _etc_hosts=()
hosts=(
"$_global_ssh_hosts[@]"
"$_ssh_hosts[@]"
"$_etc_hosts[@]"
"$HOST"
localhost
)
zstyle ':completion:*:hosts' hosts $hosts
# Use caching so that commands like apt and dpkg complete are useable
zstyle ':completion::complete:*' use-cache 1
zstyle ':completion::complete:*' cache-path ~/.oh-my-zsh/cache/
# Don't complete uninteresting users
zstyle ':completion:*:*:*:users' ignored-patterns \
adm amanda apache avahi beaglidx bin cacti canna clamav daemon \
dbus distcache dovecot fax ftp games gdm gkrellmd gopher \
hacluster haldaemon halt hsqldb ident junkbust ldap lp mail \
mailman mailnull mldonkey mysql nagios \
named netdump news nfsnobody nobody nscd ntp nut nx openvpn \
operator pcap postfix postgres privoxy pulse pvm quagga radvd \
rpc rpcuser rpm shutdown squid sshd sync uucp vcsa xfs
# ... unless we really want to.
zstyle '*' single-ignored show
if [ "x$COMPLETION_WAITING_DOTS" = "xtrue" ]; then
expand-or-complete-with-dots() {
echo -n "\e[31m......\e[0m"
zle expand-or-complete
zle redisplay
}
zle -N expand-or-complete-with-dots
bindkey "^I" expand-or-complete-with-dots
fi

9
zsh/lib/history.zsh Normal file
View File

@ -0,0 +1,9 @@
## Command history configuration
setopt append_history
setopt extended_history
setopt hist_expire_dups_first
setopt hist_ignore_dups # ignore duplication command history list
setopt hist_ignore_space
setopt hist_verify
setopt inc_append_history
setopt share_history # share command history data

65
zshrc
View File

@ -23,6 +23,9 @@ chpwd() {
# Unbreak broken, non-colored terminal
export TERM=xterm-256color
# Use vim as the editor
export EDITOR=vi
# Grep tweaks
export GREP_OPTIONS="-nRi --color --exclude-dir=tmp" # --exclude-dir=public --exclude-dir=log --exclude-dir=vendor/assets --exclude-dir=fonts --exclude-dir=images --exclude-dir=coverage --exclude-dir=rdoc"
@ -46,6 +49,11 @@ export SAVEHIST=$HISTSIZE
# Uncomment following line if you want red dots to be displayed while waiting for completion
# COMPLETION_WAITING_DOTS="true"
# Load all of the config files in ~/.zsh that end in .zsh
for config_file ($ZSH/lib/*.zsh); do
source $config_file
done
# Source my custom files after oh-my-zsh so I can override things.
source $HOME/.dotfiles/zsh/aliases
source $HOME/.dotfiles/zsh/functions
@ -54,58 +62,7 @@ source $HOME/.dotfiles/zsh/functions
export PATH=/usr/local/sbin:/usr/local/bin:${PATH}
PATH=$PATH:$HOME/bin
PATH="/usr/local/heroku/bin:$PATH"
PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
# Alias
alias ls='ls -G'
alias ll='ls -lG'
alias l='ls -laG'
alias duh='du -csh'
alias r=rails
alias g=git
alias gco='git co'
alias gst='git st'
alias gci='git ci'
alias gpff='git pff'
alias gp='git push'
alias gpom='git push origin master'
alias gf='git fetch'
alias gaa='git add --all'
alias ga='git add --update'
alias gr='git reset'
alias grh='git reset --hard'
alias gl="!source ~/.githelpers && pretty_git_log"
alias gdc='git diff --cached'
alias gam='git commit --amend'
alias gre='git remote'
alias cls=clear
alias history='fc -l 1'
alias cd-='cd -'
alias ..='cd ../'
alias ...='cd ../..'
alias cd..='cd ..'
alias cd...='cd ../..'
alias cd....='cd ../../..'
alias cd.....='cd ../../../..'
alias cd/='cd /'
# easier reload
alias reload='source ~/.zshrc'
alias beg='bundle exec guard'
# Misc
activate_virtualenv() {
if [ -f env/bin/activate ]; then . env/bin/activate;
elif [ -f ../env/bin/activate ]; then . ../env/bin/activate;
elif [ -f ../../env/bin/activate ]; then . ../../env/bin/activate;
elif [ -f ../../../env/bin/activate ]; then . ../../../env/bin/activate;
fi
}
### Added by the Heroku Toolbelt
# Shaves about 0.5s off Rails boot time (when using perf patch). Taken from https://gist.github.com/1688857
export RUBY_HEAP_MIN_SLOTS=1000000
export RUBY_HEAP_SLOTS_INCREMENT=1000000
export RUBY_HEAP_SLOTS_GROWTH_FACTOR=1
export RUBY_GC_MALLOC_LIMIT=1000000000
export RUBY_HEAP_FREE_MIN=500000
# Initialize RVM
PATH=$PATH:$HOME/.rvm/bin
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"