-
Notifications
You must be signed in to change notification settings - Fork 0
/
bashrc
193 lines (166 loc) · 4.83 KB
/
bashrc
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
# .bashrc
# User specific aliases and functions
# symlink to .bash_profile to avoid confustion and silly os things
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# git completion - prompt stuff relys on this so don't forget it
if [ -f ~/.git_completion.bash ]; then
. ~/.git_completion.bash
fi
# we use the __git_ps1 function (set by git bash-completion)
# to set the prompt (and window title)
# but sadly git isn't always installed or the completion libraries are missing
_seen_git_ps1=$( type __git_ps1 )
if [ -z "$_seen_git_ps1" ]; then
function __git_ps1() { true; }
fi
# shopt settings
shopt -s extglob
shopt -s histreedit
shopt -s histappend
shopt -s cmdhist
shopt -s histverify
shopt -s no_empty_cmd_completion
shopt -s huponexit
CVS_RSH=ssh
HISTCONTROL="ignoreboth:erasedups" # ignore duplicate commands in history
HISTIGNORE="ls:&:[bf]g:exit:ll" # ignore these commands from history
HISTTIMEFORMAT="%D %r "
MAILCHECK=15
PAGER=less
RDIST_RSH="/usr/bin/ssh"
RSYNC_RSH=ssh
VISUAL=vim
EDITOR=$VISUAL
PATH=$PATH:$HOME/bin
MANPATH=$MANPATH
export CVS_RSH VISUAL PAGER EDITOR \
RSYNC_RSH HISTIGNORE HISTCONTROL \
MAILCHECK CVSDIR SVNDIR PRINTER PATH
unset HISTFILESIZE # never truncate the history file
unset HISTSIZE # store an unlimited amount of history
# work specific rc stuff
if [ -f ~/.bashrc.work ]; then
source ~/.bashrc.work
fi
# Aliases
alias ndate="date '+%A, %B %d, %Y'"
alias gpgview='gpg --decrypt'
alias gpsort="perl -l -p -i -e '$_ = join(\",\", sort split /,/)'"
alias ls="ls --color=auto" # gnu ls only -- this gets overwritten for macosx later (bsd/posix)
alias ll="ls -l"
alias l.="ls -la"
alias rootpath="export PATH=/sbin:/usr/sbin:/usr/local/sbin:$PATH"
alias vi="vim"
alias grep="grep --color"
# I like to have root commands in my path even if I don't have perms to them
if [ -z "$ROOTPATH_RUN" ]; then
if [ x`id -u` == x0 ]; then
rootpath
export ROOTPATH_RUN="true"
fi
fi
# silly mac
case $MACHTYPE in
*-apple-darwin*)
if [ -f ~/.bashrc.macos ]; then
source ~/.bashrc.macos
fi
;;
esac
# allow completion snippets in homedir
if [ -n "$BASH_COMPLETION" ]; then
for completion_snippet in $HOME/.bash_completion.d/*; do
if [ -f "$completion_snippet" ] ;then
source $completion_snippet
fi
done
fi
# are we an interactive shell?
if [ "$PS1" ]; then
case $TERM in
xterm*)
PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}$(__git_ps1 "(%s)"):${PWD/#$HOME/~}\007";history -a'
;;
screen*)
if [ -n "$TMUX" ]; then
PROMPT_COMMAND='echo -ne "\033]0;${PWD/#$HOME/~}$(__git_ps1 "(%s)")\007";history -a'
else
PROMPT_COMMAND='echo -ne "\033k${PWD/#$HOME/~}$(__git_ps1 "(%s)")\033\\";history -a'
fi
;;
esac
# Turn on checkwinsize
shopt -s checkwinsize
# set prompt
GIT_VERSION=$(git --version 2>&1)
if [ -n "$GIT_VERSION" ]; then
PS1='[\u@\h $(__git_ps1 "(%s)")\W]\\$ '
else
PS1='[\u@\h \W]\\$ '
fi
fi
# Functions
# I can never remember the syntax for this, it has the -x to remind and clue me in to what it's doing.
function cpbytar() {
if [ $# -lt 2 ]; then
echo "cpbytar [source] [dest]"
fi
set -x
tar cf - $1 | tar xvf - -C $2
set +x
}
# used for quick finds where I don't want the git objects to show up
function nfind() {
command find . -name CVS -prune -or -name .git -prune -or -name .svn -prune -or -iname \*$*\* -print
}
# thank dog I don't use cvs much anymore, but if you did and made trees you know why this is here
function cvsdir() {
IFS='/'
for x in $*; do
if [ "$x" ]; then
mkdir $x && cvs add $x && cd $x
fi
done
}
# useful for running git operations on a tree of repos
function super-git() {
for repo in *; do
echo "# $repo"
( cd $repo && git $* )
echo "-- -- -- --"
done
}
# this sets the screen window title prior to launching ssh
# if your remote terminal doesn't have prompt_command setup correctly for screen
# set term to screen since most remote systems don't support a 256 color screen termcap
# would be nice to autodetect here but not sure if there's a way
function ssh-fix() {
args=$@
case $TERM in
screen*)
echo -ne "\033k${args##* }\033\\";
TERM=screen command ssh "$@";
;;
*)
command ssh "$@";
;;
esac
}
# page the pi (puppet info) command
function pi() {
command pi "$@" | less -F
}
# given a path long list each component
function lstree() {
echo $* | perl -F'/' -an -e 'map { print join "/", @F; print "\n" ; pop @F } @F ' | xargs ls -ld
}
# needed for puppet cloud provisioner
export RUBYLIB=~/.puppet/modules/cloud_provisioner/lib:$RUBYLIB
gam() { "/Users/ckm/bin/gam/gam" "$@" ; }
# added by travis gem
[ -f /Users/ckm/.travis/travis.sh ] && source /Users/ckm/.travis/travis.sh
# ruby fun
export RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix [email protected])"