eremite / dotfiles

Bash, irb, but mostly vim

This URL has Read+Write access

dotfiles / bashrc
100644 172 lines (146 sloc) 4.526 kb
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# ~/.bashrc: executed by bash(1) for non-login shells.
 
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
 
# don't put duplicate lines in the history. See bash(1) for more options
export HISTCONTROL=ignoredups
# ... and ignore same sucessive entries.
export HISTCONTROL=ignoreboth
# increase size of history
export HISTSIZE=1000000
shopt -s histappend
 
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
 
# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(lesspipe)"
 
# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
    debian_chroot=$(cat /etc/debian_chroot)
fi
 
# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color)
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
    ;;
*)
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
    ;;
esac
 
# Comment in the above and uncomment this below for a color prompt
#PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
 
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
    PROMPT_COMMAND='echo -ne "\033]0;$(basename `pwd`)\007"'
    ;;
*)
    ;;
esac
 
# add bin to the path
export PATH=$PATH:$HOME/bin
 
if [ "$TERM" != "dumb" ]; then
  eval "`dircolors -b`"
  alias ls='ls --color=auto'
fi
 
# enable programmable completion features
if [ -f /etc/bash_completion ]; then
  . /etc/bash_completion
fi
 
# Shows the current git branch in your shell prompt
function parse_git_dirty {
  [[ $(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)]/"
}
export PS1='\u@\h:$(parse_git_branch)\w$ '
 
# Load a rails database
function dbload {
  database=`grep -m 1 database config/database.yml | cut -d ":" -f 2`
  database=${database//[[:space:]]}
  mysql -uroot ${database} < db.sql
}
 
# Open tomboy note for this directory
function tb {
  note=$(basename `pwd`)
  if [ "$note" = `whoami` ]; then
    note="tempfile"
  fi
  if grep -q "<title>${note}</title>" $HOME/.local/share/tomboy/*; then
    tomboy --open-note $note
  else
    tomboy --new-note $note
  fi
}
 
# Get a new project from git and symlink it to $HOME
function get {
  project=${1/.git/}
  git clone ssh://git.mokisystems.com/var/repos/${project}.git /media/sda7/${project}
  cd
  ln -s /media/sda7/${project}
  cd ${project}
}
 
# ls
alias ll='ls -lh'
alias la='ls -A'
alias l='ls -1'
 
# cd
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
alias .....='cd ../../../..'
alias s='cd /etc/apache2/sites-available/'
 
# svn
alias sd='svn diff'
alias svnd='svn diff -r PREV'
alias svnr='svn resolved'
 
# git
alias gl='git pull'
alias glf='git pull amaps_franchisee master'
alias gp='git push'
alias gd='git diff'
alias gD='git diff --cached'
alias ga='git add'
alias gc='git commit -v'
alias gb='git branch'
alias gs='git status'
alias gr='git rebase'
alias gri='git rebase -i origin/master'
alias grc='git rebase --continue'
alias grh='git reset HEAD'
alias gca='git commit --amend'
alias gm='git merge'
alias gw='git whatchanged'
alias gg='git log'
alias gco='git checkout'
alias grm="git status | grep deleted | awk '{print \$3}' | xargs git rm"
alias gps='git svn dcommit'
alias gls='git svn rebase'
 
# enable tab completion
complete -o default -o nospace -F _git_checkout gm
complete -o default -o nospace -F _git_checkout gb
complete -o default -o nospace -F _git_checkout gco
 
# rails
complete -C $HOME/.rake/tab_completion -o default rake
alias t='autotest'
alias rr='rake routes | grep'
alias mig='rake db:migrate db:test:clone'
alias rs='touch tmp/restart.txt'
alias ss='ruby script/server'
alias sc='ruby script/console'
 
# logs
alias tld='tail -fn100 log/development.log'
alias tlt='tail -fn100 log/test.log'
alias tlp='tail -fn100 log/production.log'
alias tldg="tail -fn100 log/development.log | grep '###'"
alias tltg="tail -fn100 log/test.log | grep '###'"
alias lsd='less log/development.log'
alias lst='less log/test.log'
alias lsp='less log/production.log'
 
# apache
alias vhosts='sudo vim /etc/hosts'
alias rsa='sudo /usr/sbin/apache2ctl graceful'
 
# vim
alias v='vim'
 
# bash
alias x='exit'