-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.alias
More file actions
372 lines (320 loc) · 10.6 KB
/
.alias
File metadata and controls
372 lines (320 loc) · 10.6 KB
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
#! /usr/bin/env bash
# code shortcut
function code() {
# code-insiders "$1"
open -a "Cursor" "$1"
}
# Git commit, push
function gcp() {
# git commit -m "[`git rev-parse --abbrev-ref HEAD | grep --only-matching -E 'CAI-[0-9]+'`] $1"
git commit -m "$1"
git push
}
# Git commit, push, --no-verify
function gcpnv() {
# git commit -m "[`git rev-parse --abbrev-ref HEAD | grep --only-matching -E 'CAI-[0-9]+'`] $1"
git commit -m "$1"
git push --no-verify
}
# Git add, commit
function gac() {
git add .
git commit -a -m "$1"
}
# Git add, commit, push
function gacp() {
git add .
# git commit -m "[`git rev-parse --abbrev-ref HEAD | grep --only-matching -E 'CAI-[0-9]+'`] $1"
git commit -a -m "$1"
git push
}
# Git add, commit, push --no-verify
function gacpnv() {
git add .
# git commit -m "[`git rev-parse --abbrev-ref HEAD | grep --only-matching -E 'CAI-[0-9]+'`] $1"
git commit -a -m "$1" --no-verify
git push --no-verify
}
# Sneak changes into your previous commit and force push remote
function gacpp() {
git add .
git commit --amend --no-edit # git push -f
git push origin "$1" --force-with-lease # --force-with-lease ensures you do not overwrite the commits of others that have been pushed to the remote branch since your last commit!
}
# Sneak changes into previous commit - git add commit amend
function gaca() {
git add .
git commit --amend --no-edit
}
# git push --force-with-lease
function gpf() {
git push origin "$1" --force-with-lease # --force-with-lease ensures you do not overwrite the commits of others that have been pushed to the remote branch since your last commit!
}
# Git create branch
function gcb() {
git fetch
git pull
git checkout -b "$1"
git push --set-upstream origin "$1" --no-verify
}
# Git create branch
function gcbnv() {
git fetch
git pull
git checkout -b "$1"
git push --set-upstream origin "$1" --no-verify
}
# Git create local branch
function gclb() {
git fetch
git pull
git checkout -b "$1"
}
# Git checkout
unalias gc # note: ohmyzsh git plugin alias removed in .zshrc
function gc() {
echo "Checking out $1"
git checkout "$1"
}
# git create remote repo and push current branch
function gcrp() {
gh repo create "$1" --private --source=. --remote=origin --push
}
# Git branch search with interactive selection
unalias gbs # unset ohmyzsh alias
function gbs() {
# Get all branches (local and remote), filter by search term, remove HEAD ref, remove 'remote/origin/', remove '*' from current branch,
# remove spaces, sort uniquely and store in array
local branches=($(git branch -a | grep -i "$1" | grep -v "^.*HEAD" | sed 's/remotes\/origin\///' | sed 's/\*/ /' | tr -d ' ' | sort -u))
if [ ${#branches[@]} -eq 0 ]; then
echo "No matching branches found"
return 1
fi
echo "Select a branch to checkout:"
select branch in "${branches[@]}"; do
if [ -n "$branch" ]; then
git checkout "$branch"
break
else
echo "Invalid selection"
fi
done
}
# git delete local & remote branch
function gdb () {
git branch -D "$1"
echo "Deleted ${$1} locally"
git push origin --delete "$1"
echo "Deleted ${$1} remotely"
}
# git delete remote branch
function gdrb () {
git push origin --delete "$1" --no-verify
}
# git delete local branch
function gdlb () {
git branch -D "$1"
}
# github repo clone - if no slash it presumes its a personal directory on ashconnolly github
function ghrc () {
repo="$1"
parts=(${(@s:/:)repo}) # echo $parts[1] $parts[2]
if [ $parts[2] ] # has slash in string
then
gh repo clone "$1" && cd "$parts[2]"
else
gh repo clone "AshConnolly/$1" && cd "$1"
fi
}
# Git commands
# alias gs='git status -sb'
alias gs='git status'
alias gb='git branch --sort=-committerdate'
alias gf='git fetch'
alias gpull='git pull'
alias gpush='git push'
alias gd="git diff -- . ':(exclude)*package-lock.json' ':(exclude)*yarn.lock' ':(exclude)*pnpm-lock.yaml'"
alias gl="git log -n100 --pretty=format:'%Cred%h %Cgreen%ad %Cblue%an %Creset%s' --date='format:%y.%m.%d %H:%M'"
alias glf="git log -n10 --pretty=format:'%Cred%h %Cgreen%ad %Cblue%an %Creset%s' --numstat --date='format:%y.%m.%d %H:%M'"
alias gst='git stash'
alias gstp='git stash pop'
alias gsts="git stash show -p"
alias nuke='git reset --hard && git clean -f -d'
alias meganuke='git reset --hard HEAD~1 && git clean -f -d'
alias gc-='git checkout -'
alias gcd='git checkout develop'
alias gpod='git pull origin develop'
alias gcm='git checkout master'
alias gcma='git checkout main'
alias gpom='git pull origin master'
alias gpoma='git pull origin main'
alias gitremoteurl="git config --get remote.origin.url"
alias pushbranch='git push --set-upstream --no-verify origin $(git rev-parse --abbrev-ref HEAD)'
# DOCKER
alias dcu='docker-compose up'
alias dcud='docker-compose up -d'
alias dcd='docker-compose down'
alias dcb='docker-compose build'
alias dcps='docker-compose ps'
alias dps='docker ps'
alias di='docker images'
function dcu() {
docker-compose up "$1"
}
alias dk='docker kill $(docker ps -q)' # Kill all Running Containers
alias drm='docker rm $(docker ps -a -q)' # Remove all stopped Containers
# docker exec -i -t -u root <container_name> /bin/sh # Shell into container as root
# File shortcuts
alias zshreset='source ~/sites/dotfiles/.zshrc'
alias bashreset='source ~/.bashrc'
alias bashedit='code ~/sites/dotfiles/.bash_profile'
alias basheditroot='code ~/.bash_profile'
alias aliasedit='code ~/sites/dotfiles/.alias'
alias aliasreset='source ~/sites/dotfiles/.alias'
alias gitedit='code ~/sites/dotfiles/.gitconfig'
alias vscedit='code ~/Library/Application\ Support/Code/User/settings.json'
alias bashhistory='code ~/.bash_history'
alias chrome='open -a "Google Chrome" .'
# alias bashedit='open -a "Visual Studio Code" ~/sites/dotfiles/.bash_profile'
# Utilities
alias kill3000='kill -9 $(lsof -t -i:3000)'
alias list3000='lsof -i tcp:3000'
function killpid() {
kill -9 "$1"
}
# https://stackoverflow.com/questions/3855127/find-and-kill-process-locking-port-3000-on-mac
alias listall='ls -a -l'
alias tree="find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'"
# LOL don't be Jamon, ty Josh Manders - https://github.com/joshmanders/dotfiles/blob/master/config.fish#L49
# https://twitter.com/jamonholmgren/status/967548502648668161
alias rm="trash"
# Time data
alias waketime="sysctl -a |grep waketime"
alias sleeptime="sysctl -a |grep sleeptime"
alias boottime="sysctl -a |grep kern.boottime"
# NPM shortcuts
alias nrs='npm run start'
alias nrt='npm run test'
alias nrd='npm run dev'
alias nrb='npm run build'
alias nrbs='npm run build && npm run start'
alias nre='npm run export'
alias reyarn='trash yarn.lock && trash node_modules/; yarn'
alias renpm='trash package-lock.json && trash -f node_modules/; npm i'
alias rmmodules='find . -name node_modules -type d -prune -exec trash {} +'
alias npmlistg='npm list -g --depth 0'
alias npmlistglobal='npm list -g --depth 0'
alias npmlist='npm list --depth 0'
function npmiskip() {
npm i --registry=https://registry.npmjs.org "$1"
}
function nr() {
npm run "$1"
}
function npml() {
npm list "$1"
}
function npmvv() {
npm view "$1" versions
}
# usage 'nodelink 8'
linknode() {
brew link --overwrite node@$1 --force
}
unlinknode() {
brew unlink --overwrite node@$1 --force
}
# Sneak changes into your previous commit
# alias sneak='git commit -a --amend --no-edit'
# Undo the last commit, but preserve the staging area
# alias undo='git reset --soft HEAD^'
# Show number of commits from all authors.
alias stats='git shortlog -sn --all --no-merges'
# See everything everyone has done recently
alias overview='git log --oneline --no-merges'
alias getip='ipconfig getifaddr en0'
# See everything I have done recently
# alias recap='git log --oneline --no-merges --author=cashley.connolly@skybettingandgaming.com'
# See today's work
# alias today='git log --since=\"00:00:00\" --all --no-merges --oneline --author=cashley.connolly@skybettingandgaming.com'
alias restore='lwsm restore'
alias save='lwsm save'
# Other
alias hg='history|grep '
alias tsc='npx tsc --jsx preserve -t es2020 --outDir js --noEmit false'
alias hidesysprefsbadge='defaults write com.apple.systempreferences AttentionPrefBundleIDs 0 && killall Dock'
alias showsysprefsbadge='defaults write com.apple.systempreferences AttentionPrefBundleIDs 1 && killall Dock'
#
# File conversion
#
# https://superuser.com/questions/378726/convert-from-mov-to-mp4-container-format
function movtomp4() {
ffmpeg -i "$1".mov -c copy "$1".mp4
# ffmpeg -i my-video.mov -vcodec h264 -acodec mp2 my-video.mp4
}
# https://superuser.com/a/1555285
function movtomp4encode() {
ffmpeg -i "$1".mov -c:v libx264 -c:a aac -vf format=yuv420p -movflags +faststart "$1".mp4
}
# https://engineering.giphy.com/how-to-make-gifs-with-ffmpeg/
# https://superuser.com/questions/436056/how-can-i-get-ffmpeg-to-convert-a-mov-to-a-gif
# usage: "vidtogif hello.mov", "vidtogif hello.mp4" etc
function vidtogif() {
str="$1"
splitChar=":"
parts=(${(@s:splitChar:)str})
# echo $parts
ffmpeg -ss 00:00:00.000 -i $parts[1].$parts[2] -pix_fmt rgb24 -r 10 $parts[1].gif
# ffmpeg -ss 00:00:00.000 -i untitled.mov -pix_fmt rgb24 -r 10 untitled.gif
}
# alias ll='ls -la'
# Updating git ignore - untracked file removal
# commit current changes or you will lose them
# git rm -r --cached .
# git add .
# git commit -m "fixed untracked files"
# Get the current branch name (not so useful in itself, but used in
# other aliases)
# alias branchname='git rev-parse --abbrev-ref HEAD'
# Push the current branch to the remote "origin", and set it to track
# the upstream branch
# alias publish='git push -u origin $(alias branchname)'
# For loop to open all subdirectories in vscode
# function openfoldersincode() {
# declare -a dirs
# i=1
# for d in */
# do
# dirs[i++]="${d%/}"
# done
# echo "There are ${#dirs[@]} dirs in the current path."
# for((i=1;i<=${#dirs[@]};i++))
# do
# echo $i "${dirs[i]}"
# code "${dirs[i]}"
# done
# # https://stackoverflow.com/a/4494667/2627434 - select works too for interactive selection
# # echo "which dir do you want?"
# # echo -n "> "
# # read i
# # echo "you selected ${dirs[$i]}"
# # cd "${dirs[$i]}"
# }
# For loop for opening an array of folders in vscode
function loopFunc() {
declare -a arr1=(
"branch-hello"
"branch-goodbye"
)
for i in "${arr1[@]}"
do
git branch -d "$i"
done
}
# https://unix.stackexchange.com/questions/19654/how-do-i-change-the-extension-of-multiple-files
# renaming - not needed
# for file2 in *.webp;
# do
# echo $file2
# mv -- "$file2" "${file2%.png.webp}.webp"
# done