-
Notifications
You must be signed in to change notification settings - Fork 0
/
.bash_aliases
399 lines (297 loc) · 7.31 KB
/
.bash_aliases
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
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
alias copyssh="pbcopy < $HOME/.ssh/id_rsa.pub"
alias flushdns="sudo killall -HUP mDNSResponder"
alias now="echo $(date "+%Y-%m-%d-%H%.%M.%S") | pbcopy"
alias r="cd $HOME/Repos"
alias reloadcli="echo 'Re-sourcing bash profile'; source $HOME/.bash_profile"
alias today="echo `date +%Y-%m-%d` | pbcopy"
alias y="$(which yarn)"
alias cda="composer dump-autoload -o"
alias v="vagrant"
alias vu="v up"
alias vssh="v ssh"
alias vim="/usr/local/bin/vim"
alias vi="vim"
editaliases() {
vi "$HOME/.bash_aliases"
}
sync() {
git status &> /dev/null
local git_status="${?}"
if [[ "$git_status" -ne 0 ]]; then
printf "Not a git repository.\n"
return 128
fi
local branch_name=${1:-development}
local current_branch=$(git branch | grep \* | awk '{print $2}')
printf "Merging '$branch_name' into '$current_branch'\n"
git fetch origin "$branch_name:$branch_name"
git merge $branch_name
}
# Spawn a selenium server on local
selenium() {
local port pids
# Port to use. Defaults to 5555
port="${1:-5555}"
# Get pids to delete before spawning the selenium service
pids=$(lsof -i "tcp:${port}" | grep 'LISTEN' | awk '{print $2}')
if [ ! -z "$pids" ]; then
printf "Killing existing processes that use port $port.\n"
kill -9 $pids
fi
printf "Starting selenium server on port $port.\n"
selenium-server -port $port
}
devmaster() {
local link
link="${1}"
if [ -z $link ]; then
echo "Enter a link!"
return 1
fi
echo "Hi @here, can I get a :approvamundo: dev->master :approvamundo: approval for this: $link" | pbcopy
echo "Copied to clipboard"
return 0
}
_ssh()
{
local cur prev opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts=$(grep '^Host' ~/.ssh/config | grep -v '[?*]' | cut -d ' ' -f 2-)
COMPREPLY=( $(compgen -W "$opts" -- ${cur}) )
return 0
}
complete -F _ssh ssh
a() {
app="$PWD/artisan"
if [ ! -f ${app} ]; then
echo "Not a Laravel project."
return 1
fi
$(which php) ${app} ${@}
}
acc() {
a clear-compiled ${@}
cmp dump-autoload
}
acl() {
file="${1:-$PWD}"
ls -le $file
}
am() {
a migrate ${@}
}
amr() {
a migrate:refresh ${@}
}
arl() {
a route:list ${@}
}
botman() {
if [ -z "$(which botman)" ]; then
echo "BotMan is not installed. Would you like to install it?"
botman_install_pattern="^y(es)?$"
read botman_install
shopt -s nocasematch
if [[ $botman_install =~ $botman_install_pattern ]]; then
composer global require botman/installer
else
return 1
fi
fi
$(which botman) ${@}
}
bot() {
botman ${@}
}
branchout() {
git status &> /dev/null
ret_git_status=$?
if [ ! $ret_git_status -eq 0 ]; then
echo "Not a Git repository."
return $ret_git_status
fi
echo ""
default_start_branch="development"
echo "Branch from? (Default: $default_start_branch)"
read start_branch
echo ""
start_branch=${start_branch:=$default_start_branch}
git rev-parse --verify $start_branch &> /dev/null
ret_start_branch=$?
if [ ! $ret_start_branch -eq 0 ]; then
echo "Not a valid Git branch."
return $ret_start_branch
fi
default_author_name="jc"
echo "Your name? (Default: $default_author_name)"
read author_name
echo ""
author_name=${author_name:=$default_author_name}
issue_summary=""
while [ ${#issue_summary} -le 0 ]; do
echo "Enter the issue summary:"
read issue_summary
issue_summary="$(echo $issue_summary | sed -e 's/[^[:alnum:]]/-/g' | awk '{ print tolower($0) }')"
echo ""
done
issue_key=""
issue_key_pattern="[a-z]{3,}-[0-9]+"
issue_key_pattern_match=false
shopt -s nocasematch
while [ $issue_key_pattern_match = false ]; do
echo "Enter the issue key:"
read issue_key
echo ""
if [[ $issue_key =~ $issue_key_pattern ]]; then
issue_key_pattern_match=true
fi
done
issue_key=$(echo $issue_key | awk '{print toupper($0)}')
git checkout -b "$author_name-$issue_summary-$issue_key" "$start_branch"
}
changes() {
git status ${@}
}
chrome() {
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome ${@}
}
cls() {
clear ${@}
}
composer() {
$(which php) -n -d memory_limit=-1 $(which composer) ${@}
}
cmp() {
composer ${@}
}
d() {
cd ~/Desktop ${@}
}
# Deletes stale Git branches
dsb() {
echo "Deleting stale Git branches..."
git branch --merged | egrep -v "(^\*|master|dev)" | xargs git branch -d
}
edit() {
file="$1"
app="TextEdit"
if [ ! -f ${file} ]; then
echo "$file is not a file."
return 1
fi
/usr/bin/open -a ${app} ${file}
}
# "apply develop" on current branch
gad() {
current_branch="$(git rev-parse --abbrev-ref HEAD)"
dev_branch="development"
repository="origin"
$(which git) fetch --update-head-ok $repository $dev_branch:$current_branch
}
gb() {
$(which git) branch ${@}
}
gc() {
$(which git) checkout ${@}
}
gd() {
$(which git) diff ${@}
}
gp() {
$(which git) push ${@}
}
gs() {
$(which git) status ${@}
}
gulp() {
if [ -f "$PWD/node_modules/.bin/gulp" ]; then
"$PWD/node_modules/.bin/gulp" ${@}
else
echo "No local version of gulp installed."
return 1
fi
}
ll() {
ls -la ${@}
}
mk() {
dir="$1"
if [ ! -d "$dir" ]; then
pattern="^y(es)?$"
echo "Directory '$dir' does not exist. Would you like to create it? (Y/N)"
read createdir
if [[ $createdir =~ $pattern ]]; then
shopt -s nocasematch
mkdir -p "$dir"
else
return 1
fi
fi
cd "$dir"
}
nah() {
git reset --hard && git clean -df
}
phpstorm() {
path=${1}
app="/Applications/PhpStorm.app"
if [ -z ${loc} ] || [ ! -d ${path} ]; then
path=${PWD}
fi
/usr/bin/open -a ${app} ${PWD}
}
phplinter() {
linter="$PWD/bin/phpcs-fixer"
if [ ! -f $linter ]; then
echo "php-cs-fixer does not exist."
return 1
fi
target_branch="${1:-development}"
current_branch="${2:-$(git rev-parse --abbrev-ref HEAD)}"
IFS=$'\n'
changed_files="$(git diff --name-only $target_branch..$current_branch)"
unset IFS
$linter fix --config=.php_cs.dist -v --dry-run --using-cache=no --path-mode=intersection $changed_files
}
psysh() {
local_app="$PWD/vendor/bin/psysh"
args="$@"
if [ -f $local_app ]; then
echo "Loading local version of PsySH."
$local_app $args
fi
which psysh &> /dev/null
psysh_exists="$?"
if [ $psysh_exists -gt 0 ]; then
echo "PsySH does not exist."
return $psysh_exists
fi
echo "Loading global version of PsySH."
$(which psysh) $args
}
repo() {
repo=${1}
repo_path="$HOME/Repos/$repo"
if [ ! -d ${repo_path} ]; then
echo "Not a valid repo location."
return 1
fi
echo "Switching to '$repo_path'..."
echo ""
cd ${repo_path}
}
t() {
a tinker ${@}
}
today() {
echo `date +%Y-%m-%d`
}
u() {
app="$PWD/phpunit"
if [ ! -f ${app} ]; then
app="$PWD/vendor/bin/phpunit"
fi
$(which php) ${app} ${@}
}