-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.bash_profile
318 lines (254 loc) · 7.23 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
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
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
# Bash
alias vimbash="vim ~/.bash_profile"
alias rebash="source ~/.bash_profile"
alias ..="cd .."
# General
alias dr="docpad run"
alias dg="docpad generate"
alias cl="clear; pwd"
alias l="ls -las"
alias ls='l'
alias h="history"
alias off="out"
alias fixgit="fix"
# Git Autocomplete
source ~/git-completion.bash
# Navigate to Sites
alias cds="cd ~/Sites/"
# Application
alias clearcache=""
alias pear="/Applications/MAMP/bin/php/php5.5.3/bin/pear"
alias drush="/Applications/MAMP/bin/php/php5.5.3/bin/drush"
# Update SLocate DB
alias uplocate="sudo /usr/libexec/locate.updatedb"
# Git
alias g="git"
alias ga="git add"
alias gs="git status"
alias gc="git commit"
#alias go="git checkout" # replaced by function
alias gd="git diff"
alias gf="git fetch"
alias gl="git log"
alias gh="git push"
alias gb="git branch"
alias gdc="git diff --cached"
# Tasks
alias gt="gettask"
alias st="settask"
gitInit() {
git init;
git remote add origin https://github.com/iredmedia/$1.git;
}
old_rebash () {
CURRENT_TASK=$TASK;
source ~/.bash_profile
TASK=$CURRENT_TASK;
}
# Checkout specified branch, or the current branch while setting task shortcut
go () {
if [ $# -eq 1 ]; then
git checkout $1;
else
git checkout $(getBranch);
fi
settask;
}
# Grep GIT logs for a certain task number
# $1 Jira task number
gitgrep () {
git log --grep "$1" --name-status;
}
# Set current working task number
settask () {
if [ $# -eq 1 ]; then
TASK=$1;
else
TASK=`getCommitMessage`;
fi
}
# Return current working task number
gettask () {
echo $TASK;
}
# Do an amend
amend () {
git commit --amend $1
}
# Do a commit based on value from setTask
commit () {
git commit -m"$TASK $1";
}
# Fix a corrupt git index
fix () {
rm -rf .git/index && git reset;
#git fsck;
}
# Get the current working branch
getBranch () {
BRANCH=`git rev-parse --abbrev-ref HEAD`
echo $BRANCH;
}
# Get the commit message 'task #' delimiter
getCommitMessage () {
currentBranch=$(getBranch);
IFS='- ' read -a array <<< ${currentBranch};
echo "${array[0]}-${array[1]}";
}
# Push to current working branch
push () {
PROJECT=$(getBranch);
echo "Pushing to $PROJECT";
git push origin $PROJECT
}
# Pull from current working branch
pull () {
PROJECT=$(getBranch)
echo "Pulling from $PROJECT";
git pull origin $PROJECT;
git fetch;
}
# Fetch & Rebase
fetch () {
git fetch; git rebase;
}
# Retrieve a branch, pull its changes, run composer & bin/prep
get () {
PROJECT=$(getBranch)
if [ $# -eq 1 ]
then
PROJECT=$1
fi
# while test $# -gt 0; do
# case "$1" in
# -r|--run)
# docpad='docpad run'
# break
# ;;
# -g|--generate)
# docpad='docpad generate'
# break
# ;;
# esac
# done
git checkout $PROJECT && git pull origin $PROJECT && docpad generate #&& `${docpad}`
}
# At set interval, repeatedly touch files
touchme () {
while true
do
touch ~/application/$1
sleep 3
done
}
# Touch all SCSS files once
css () {
touch `find . -name *.scss`
}
# Restart apache
restartapache () {
sudo service apache2 restart;
}
diff_head () {
git diff HEAD^1
}
commit_diff () {
git log --color -p --full-diff
}
# backup $foldername: create a backup of this under ~/Documents/backups
backup () {
# Define directory as a string/variable
backupDir=~/Documents/backups/"nde-`date "+%d-%m-%H00"`";
# Check to see if backup directory exists, if not then make the directory
if [ -d $backupDir ]
then
backupDir=~/Documents/backups/"nde-`date "+%d-%m-%H%M"`";
echo "Backup Already Exists, creating newer folder";
fi
mkdir `echo $backupDir`;
echo "Directory created at $backupDir";
scp -r [email protected]:~/site-steve/src $backupDir;
echo "Backup completed at $backupDir";
# Change to directory if "cd" is provided
if [[ "$@" == "cd" ]]
then
cd $backupDir;
echo "Now in backup directory";
fi
# Echo output to user
echo "Done";
}
# off: shutdown VM gracefully
out () { exit; }
# lsf: list folder content in full details
lsf () { ls -als $1; }
# searchfor: search for $@ string in the current directory but filter out svn files
searchfor () {
echo -e "Searching for \033[1;33m$@\033[0m in \033[1;33m$PWD\033[0m";
grep -rins "$@" . | grep -v svn | grep -rins "$@";
echo "";
}
# detmp: recursively remove all files which their names start with ._ under the current directory
detemp() {
echo "Recursively removing all files which their names start with ._ under the current directory:";
rm -f `find . -type f -name "._*"`;
echo "Done.";
}
# sad: search for $1 and replace by $2 in the current directory
sad() { grep -rls $1 . | grep -v svn | xargs sed -i -e "s/$1/$2/"; }
# bdiff: wrapper for comparing two folders with svn filtered out
bdiff() { diff -r $1 $2 | grep -v svn; }
# compare: find the difference between branch $1 and $2 in folder $3
compare() { diff -Naur ~/Projects/$1/branch/$3 ~/Projects/$2/branch/$3; }
# Searchings:
# ff: to find a file in the current directory
ff () { /usr/bin/find . -name "$@" ; }
# ffs: to find a file whose name starts with a given string
ffs () { /usr/bin/find . -name "$@"'*' ; }
# ffe: to find a file whose name ends with a given string
ffe () { /usr/bin/find . -name '*'"$@" ; }
# findlarger: find all files larger than $1 byte under the current folder
findlarger() { find . -type f -size +${1}c ; }
# Terminal Colors
export CLICOLOR=1
export LSCOLORS=exfxcxdxbxegedabagacad
# grep Colors
export GREP_OPTIONS='--color=auto'
export GREP_COLOR='1;32'
export EDITOR="vim"
#export PATH=/usr/local/bin:$PATH
#export PATH="/Applications/MAMP/Library/bin:/Applications/MAMP/bin/php5.4/bin:$PATH"
#export PATH="/usr/local/bin:$HOME/.rbenv/bin:$PATH:~/bin:/usr/local/php5/bin:/usr/local/git/bin:$PATH"
export PATH="$HOME:~/bin:/usr/local/php5/bin:/usr/local/git/bin:$PATH"
export PATH="$HOME/.rbenv/bin:$PATH"
if [[ ! -x $(which fink) && -d /sw/bin ]];then
source /sw/bin/init.sh
fi
# Default
PS1="\[\e[1;30m\]#!\!\e[m \[\e[1;33m\]\u\[\e[m\] in \[\e[1;33m\]\w\[\e[m\] on \[\e[1;33m\]\h\[\e[m\] \`if [ \$? = 0 ]; then echo -e '\[\e[01;33m\]\n\xE2\x98\xBA'; else echo -e '\[\e[01;31m\]\n\xE2\x98\xB9'; fi\` \[\e[01;34m\]\[\e[00m\]"
# Smiley
# PS1="\w \`if [ \$? = 0 ]; then echo -e '\[\e[01;32m\]\n\xE2\x98\xBA'; else echo -e '\[\e[01;31m\]\n\xE2\x98\xB9'; fi\` \[\e[01;34m\]\[\e[00m\]"
# Smiley 2 (\w is the cwd, \$ is ??)
# PS1="\w \`if [ \$? = 0 ]; then echo -e '\[\e[01;32m\]\n\xE2\x98\xBA'; else echo -e '\[\e[01;31m\]\n\xE2\x98\xB9'; fi\` \[\e[01;34m\]\[\e[00m\]"
# PS1="echo -e '\[\e[01;31m\]\n\xE2\x98\xB9'"
# Initialize
git config --global color.ui true;
cds; cd neompd
clear;
git status;
# Variables
#APP=~/application
#BRANCH=`git rev-parse --abbrev-ref HEAD`;
BRANCH=`getCommitMessage`;
TASK=`getCommitMessage`;
eval "$(rbenv init -)"
# {{{
# Node Completion - Auto-generated, do not touch.
shopt -s progcomp
for f in $(command ls ~/.node-completion); do
f="$HOME/.node-completion/$f"
test -f "$f" && . "$f"
done
# }}}
### Added by the Heroku Toolbelt
export PATH="/usr/local/heroku/bin:$PATH"