mattman (owner)

Revisions

gist: 87359 Download_button fork
public
Description:
.bashrc
Public Clone URL: git://gist.github.com/87359.git
Text only
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# -----------
# General
# -----------
alias ..='cd ..'
alias ll='ls -lh'
alias la='ls -la'
alias ps='ps -ax'
alias du='du -hc'
alias cd..='cd ..'
alias today='date +"%A, %B %d, %Y"'
alias yest='date -v-1d +"%A %B %d, %Y"'
alias recent='ls -lAt | head'
alias ebashrc='mate ~/.bashrc'
alias mbashrc='mate ~/.bashrc'
alias sbashrc='source ~/.bashrc'
 
# -------------
# Shortcuts
# -------------
alias c="clear"
alias m="mate"
 
# -------
# Git
# -------
alias ga='git add'
alias gs='git status'
alias gd='git diff'
alias github="open \`git config -l | grep 'remote.origin.url' | sed -En 's/remote.origin.url=git(@|:\/\/)github.com(:|\/)(.+)\/(.+).git/https:\/\/github.com\/\3\/\4/p'\`"
 
# ---------
# Rails
# ---------
alias gemi='sudo gem install --no-rdoc --no-ri'
alias sg='script/generate'
alias ss='script/server'
alias sc='script/console'
alias sl='open http://localhost:3000'
alias mig='rake db:migrate db:test:prepare'
alias allspecs='spec -fs -c spec'
alias preptest='rake db:migrate db:test:prepare && rake RAILS_ENV=test ts:config ts:start ts:in'
 
# ---------------
# Environment
# ---------------
export PATH="$PATH:/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin"
export PATH="$HOME/bin/:$PATH"
export HISTSIZE=10000
export HISTFILESIZE=10000
export PAGER=less
export CLICOLOR=1
export EDITOR="/usr/bin/mate -w"
 
# ---------
# Prompt
# ---------
 
git_prompt_info() {
  branch_prompt=$(__git_ps1)
  if [ -n "$branch_prompt" ]; then
    status_icon=$(git_dirty)
    echo $branch_prompt $status_icon
  fi
}
 
# Show character if changes are pending
git_status() {
  if git status | grep 'to be commit' > /dev/null; then
    echo "☠"
  fi
}
 
git_dirty() {
  git st 2>/dev/null | wc -l | awk '{if ($1 > 2) print "☠"}'
}
 
 
function prompt {
local BLACK="\[\033[0;30m\]"
local RED="\[\033[0;31m\]"
local GREEN="\[\033[0;32m\]"
local YELLOW="\[\033[0;33m\]"
local BLUE="\[\033[0;34m\]"
local PURPLE="\[\033[0;35m\]"
local CYAN="\[\033[0;36m\]"
local WHITE="\[\033[0;37m\]"
local WHITEBOLD="\[\033[1;37m\]"
export PS1="${CYAN}\w${GREEN} \$(git_prompt_info)${WHITE} \$ "
}
prompt
 
# ------------------
# Autocompletes
# ------------------
 
complete -C ~/rake_complete.rb -o default rake
complete -C ~/cap_complete.rb -o default cap
 
# ---------
# Other
# ---------
 
# Cool History Summerizer
historyawk(){ history|awk '{a[$2]++}END{for(i in a){printf"%5d\t%s\n",a[i],i}}'|sort -nr|head; }
 
# cd directly to a dir and list contents
cdl() {
  if [ "$1" ]
  then builtin cd "$1" && ll
  else builtin cd && ll
  fi
}
 
function nth {
  osascript -e "
  Tell application \"Terminal\"
    activate
    tell application \"System Events\" to tell process \"Terminal\" to keystroke \"t\" using command down
    do script with command \"cd '$(pwd)'; clear\" in selected tab of the front window
  end tell"
}
 
_mategem()
{
    local curw
    COMPREPLY=()
    curw=${COMP_WORDS[COMP_CWORD]}
    local gems="$(gem environment gemdir)/gems"
    COMPREPLY=($(compgen -W '$(ls $gems)' -- $curw));
    return 0
}
complete -F _mategem -o dirnames mategem