-
Notifications
You must be signed in to change notification settings - Fork 7
/
.bash_profile
148 lines (112 loc) · 3.89 KB
/
.bash_profile
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
# ~/.bash_profile
# set INPUTRC (so that .inputrc is respected)
export INPUTRC=~/.inputrc
# add various directories to PATH
PATH=~/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:$PATH
export PATH
# umask
umask 022
# aliases
alias ll='ls -al'
alias l='ls -l'
alias mc='mc -cu'
alias ..='cd ..'
alias ...='cd ../..'
alias ack='ack-grep'
alias diff='colordiff -u'
alias wtf='git wtf'
# g alias with bash completion
alias g='git'
complete -o bashdefault -o default -o nospace -F _git g 2>/dev/null || complete -o default -o nospace -F _git g
# rails
alias r='rails'
alias b='bundle'
alias bundler='bundle'
alias bi='b install'
alias bu='b update'
alias be='b exec'
# Rails production environment by default for all non-development machines
[[ $(hostname -s) != 'ubuntu' ]] && [[ $(hostname -s) != 'genesis' ]] && export RAILS_ENV="production"
# Heroku
alias hcp='heroku console --remote production'
alias hcs='heroku console --remote staging'
alias hlp='heroku logs -t --remote production'
alias hls='heroku logs -t --remote staging'
# colored ls (one version for GNU, other for Mac OS X)
if `which dircolors` > /dev/null; then
eval "`dircolors -b`"
alias ls='ls --color=auto'
else
export CLICOLOR=1
fi
# make less always work with colored input
alias less='less -R'
# make watch always work with colored input
alias watch='watch --color'
# subversion
alias svndiff='svn diff --diff-cmd=colordiff'
alias svnaddall='svn status | awk "/\\?/ {print \$2}" | xargs svn add'
# auto-correct directory spelling errors
shopt -s cdspell
# extended pattern matching features enabled
shopt -s extglob
# make bash append rather than overwrite the history on disk
shopt -s histappend
# perform hostname completion when a word containing a @ is being completed
shopt -s hostcomplete
# allow a word beginning with # to cause that word and all remaining characters on that line to be ignored
shopt -s interactive_comments
# bash will not attempt to search the PATH for possible completions when completion is attempted on an empty line
shopt -s no_empty_cmd_completion
# case insensitive matching when performing pathname expansion
shopt -s nocaseglob
# whenever displaying the prompt, write the previous line to disk
# so new shell gets the history lines from all previous shells
export PROMPT_COMMAND='history -a'
# don't put duplicate lines in the history
export HISTCONTROL=ignoredups
# increase history limit (100KB or 5K entries)
export HISTFILESIZE=100000
export HISTSIZE=5000
# set defaul bash editor (for crontab et al.)
EDITOR=/usr/bin/vim
VISUAL=/usr/bin/vim
export EDITOR
export VISUAL
# turn off terminal driver flow control (CTRL+S/CTRL+Q) (if we are a terminal)
if [ -t 0 ]; then
stty -ixon -ixoff
fi
# 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)"
# source bash_completion
if [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
# git function
function scoreboard () {
git log | grep Author | sort | uniq -ci | sort -hr
}
# RVM (load conditionally if exists)
if [ -x "$HOME/.rvm/scripts/rvm" ]; then
source "$HOME/.rvm/scripts/rvm"
PATH=$PATH:$HOME/.rvm/bin
fi
# set DISPLAY if Xvfb is running (expects it to run on :0)
xdpyinfo -display :0 &>/dev/null && export DISPLAY=:0
# PS1 (shell prompt)
# 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
function parse_git_dirty {
git diff --quiet HEAD &>/dev/null
[[ $? == 1 ]] && echo "⚡"
}
function parse_git_branch {
local branch=$(__git_ps1 "%s")
[[ $branch ]] && echo "[$branch$(parse_git_dirty)]"
}
PS1="${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\$(parse_git_branch)\[\033[00m\]\$ "