forked from crccheck/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.crcrc
276 lines (226 loc) · 7.08 KB
/
.crcrc
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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
#!/bin/sh
###################################################
### Functions
###################################################
# append_path() and prepend_path() adapted from Fink's init.sh
# add to end of path
append_path()
{
if eval test -z "\$$1"
then
eval "export $1=$2"
fi
if ! eval test -z "\"\${$1##*:$2:*}\"" -o -z "\"\${$1%%*:$2}\"" -o -z "\"\${$1##$2:*}\"" -o -z "\"\${$1##$2}\""
then
eval "export $1=\$$1:$2"
fi
}
# add to beginning of path
prepend_path()
{
if eval test -z "\$$1"
then
eval "export $1=$2"
return
fi
if ! eval test -z "\"\${$1##*:$2:*}\"" -o -z "\"\${$1%%*:$2}\"" -o -z "\"\${$1##$2:*}\"" -o -z "\"\${$1##$2}\""
then
eval "export $1=$2:\$$1"
fi
}
prepend_path_if_exists()
{
if [ -d "$2" ]
then
prepend_path $1 $2
fi
}
###################################################
### PATH-type list variables
###################################################
prepend_path PATH /usr/local/bin
prepend_path PATH $HOME/usr/bin
prepend_path PATH $HOME/bin
prepend_path PATH $HOME/local/node/bin
for i in $HOME/opt/*/bin
do
prepend_path_if_exists PATH $i
done
prepend_path_if_exists PATH "$HOME/opt/android-sdk-linux_x86-1.5_r1/tools"
# Note to self: as of Python 2.6, there is now support for local
# site-packages in ~/.local/. See PEP-370.
# Better yet, just use virtualenv.
#append_path PYTHONPATH $HOME/.python
append_path LD_LIBRARY_PATH $HOME/lib:$HOME/usr/lib
###################################################
### Simple variables
###################################################
if [ -z "$HOST" ]
then
HOST=$(hostname | sed 's/\..*//')
fi
export EDITOR=vim
export VISUAL=vim
export LC_COLLATE="POSIX"
if [ "$TERM" == "xterm" ]
then
export TERM="xterm-color"
fi
# Change the window title of X terminals
case $TERM in
xterm*|rxvt|Eterm|eterm)
PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/$HOME/~}\007"'
;;
screen)
PROMPT_COMMAND='echo -ne "\033_${USER}@${HOSTNAME%%.*}:${PWD/$HOME/~}\033\\"'
;;
esac
# Python stuff
export PIP_DOWNLOAD_CACHE="$HOME/.pip"
function f {
if [ -z $1 ]; then
fab -l
else
fab $@
fi
}
###################################################
### Aliases
###################################################
alias l='ls -la'
alias sl='sl -e'
alias vi='vim -g'
# to install ack-grep as ack instead of ack-grep:
# sudo dpkg-divert --local --divert /usr/bin/ack --rename --add /usr/bin/ack-grep
#todo alias rm to move shit to /tmp
alias mv='mv -iv'
alias cp='cp -iv'
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
alias .....='cd ../../../..'
alias grep='grep -I --color=auto'
alias fgrep='fgrep -I --color=auto'
alias egrep='egrep -I --color=auto'
alias rgrep='rgrep -I --color=auto'
alias netstat='netstat -natp'
alias du='du -kh --max-depth=1'
alias df='df -kTh'
alias wget='wget --no-check-certificate'
my_port=8000
alias dj='django runserver 0.0.0.0:$my_port'
alias djp='django runserver_plus 0.0.0.0:$my_port'
#alias djl='python manage.py runserver 0.0.0.0:$my_port --settings=local-settings'
#alias djpl='python manage.py runserver_plus 0.0.0.0:$my_port --settings=local-settings'
alias djs="django shell"
alias djsp="django shell_plus"
alias djsql="django debugsqlshell"
alias attach="$HOME/bin/grabssh ; screen -d -r"
alias fixssh="source $HOME/bin/fixssh"
alias ipchicken="curl -s http://checkip.dyndns.org | sed 's/[a-zA-Z/<> :]//g'"
alias yahoo="ping -i 10 www.yahoo.com"
alias fb="fab -f ~/scripts/fabfile.py"
###################################################
### Platform- or system-specific modifications
###################################################
if [ "$(uname -s)" == "Darwin" ]; then
# Mac OS X stuff:
alias ls='ls -AFGq'
append_path PYTHONPATH ~/Library/Python
# Fix Backspace/Delete confusion:
stty erase ^?
# XTerm's $MANPATH gets messed up, and I can't find where it's happening.
# Screw it. Just reset the whole thing, cuz the default works.
unset MANPATH
# xcode 4 hack, to get pycrypto to install
export ARCHFLAGS='-arch i386 -arch x86_64'
source $HOME/.dotfiles/git-completion.bash
alias vi='mvim'
export EDITOR=vi
export VISUAL=mvim
else
alias ls='ls -F --color=auto'
fi
###################################################
### virtualenvwrapper
###################################################
export WORKON_HOME=$HOME/env
if [ ! -d $WORKON_HOME ]; then
mkdir -p $WORKON_HOME
fi
[ -f /usr/local/bin/virtualenvwrapper.sh ] && source /usr/local/bin/virtualenvwrapper.sh
export PIP_VIRTUALENV_BASE=$WORKON_HOME
export PROJECT_HOME=$HOME/dev
if [ ! -d $PROJECT_HOME ]; then
mkdir -p $PROJECT_HOME
fi
#UNCOLOR="\[\033[00m\]"
#COLOR="\[\033[1;36m\]"
###################################################
### RVM
###################################################
# This loads RVM into a shell session
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
###################################################
### Ruby Gems
###################################################
export GEM_HOME=$HOME/.gem/ruby/1.8
prepend_path PATH /var/lib/gems/1.8/gems/s3-sync-1.2.7/bin
prepend_path PATH $GEM_HOME/bin
append_path PATH /var/lib/gems/bin
###################################################
### git prompt hack
###################################################
# http://henrik.nyh.se/2008/12/git-dirty-prompt
# http://www.simplisticcomplexity.com/2008/03/13/show-your-git-branch-name-in-your-prompt/
# username@Machine ~/dev/dir[master]$ # clean working directory
# username@Machine ~/dev/dir[master*]$ # dirty working directory
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/* \(.*\)/ (Git branch: \1$(parse_git_dirty))/"
}
VIRTUAL_ENV_DISABLE_PROMPT="True"
function active_virtualenv {
if [ -n "$VIRTUAL_ENV" ]
then
#echo -n " (Virtualenv: $COLOR\$(basename "$VIRTUAL_ENV")$UNCOLOR)"
echo -n " (Virtualenv: $(basename "$VIRTUAL_ENV"))"
fi
}
# Stolen from Gentoo:
PS1="\n\[\033[01;32m\]\u@\h\[\033[01;34m\] \w\[\033[00m\]\$(active_virtualenv)\$(parse_git_branch)\n\$ "
#LIGHT_GREEN="\[\033[1;32m\]"
#PS1="$LIGHT_GREEN\u@\h\[\033[01;34m\] \w$UNCOLOR$(active_virtualenv)$(parse_git_branch)\n\$ "
# Save custom PS1 to restore later
#export CCG_PS1="$PS1"
export PS1
function _pingbaby {
# TODO scale=5
# TODO delay=10
local out=$(ping -q -c 1 $1)
local time=$(echo $out | awk -F/ 'END{print $5}')
if [ $time ]; then
local ticks=$(echo $time / 5 | bc)
for i in $(seq $ticks); do echo -n '▄'; done
echo " $time"
else
echo " * p i n g t i m e o u t *"
fi
sleep 10
_pingbaby $1
}
function pingbaby {
local host='www.yahoo.com'
echo Pinging $host
_pingbaby $host
}
# mktmpenv doesn't work too well for me
function tmpenv {
deactivate
rmvirtualenv tmp
mkvirtualenv tmp --no-site-packages
workon tmp
pip freeze
}