-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.aliases.local.example
116 lines (89 loc) · 3.72 KB
/
.aliases.local.example
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
# Modify this file to be `.aliases.local` for your own local/personal usage.
###################################################################################
# Blog Operation: Hugo
###################################################################################
PATH_BLOG=~/projects/ernestchiang/www
PATH_DEFAULT_SCREENCAPTURE="/Users/dwchiang/Dropbox/Screenshots"
alias blogd="cd '$PATH_BLOG'"
function blogserv() {
cd $PATH_BLOG
open "/Applications/Arc.app" http://localhost:1313
hugo server --buildDrafts --buildFuture --disableFastRender --watch --logLevel info
}
function blogservnodraft() {
cd $PATH_BLOG
open "/Applications/Arc.app" http://localhost:1313
hugo server --watch --logLevel info
}
function hugonew() {
cd $PATH_BLOG && ./hugo-new-post.sh $1 && code .
}
function move-image-here() {
mv ~/Downloads/image.jpg $(pwd -P)/index.jpg
}
###################################################################################
# Screen Capture Location
###################################################################################
function scapture-here() {
info 'Changing default screencapture location from:'
defaults read com.apple.screencapture location
defaults write com.apple.screencapture location $(pwd -P)
success 'Changed default screencapture location to:'
defaults read com.apple.screencapture location
info 'Remember to execute `screencapture-default`'
}
function scapture-default() {
info 'Changing default screencapture location from:'
defaults read com.apple.screencapture location
defaults write com.apple.screencapture location ${PATH_DEFAULT_SCREENCAPTURE}
success 'Changed default screencapture location to:'
defaults read com.apple.screencapture location
}
# Image Optimization
alias imgoptim="/Applications/ImageOptim.app/Contents/MacOS/ImageOptim"
###################################################################################
# Docker tools
###################################################################################
function dockertags() {
if [ $# -lt 1 ]
then
cat << HELP
dockertags -- list all tags for a Docker image on a remote registry.
EXAMPLE:
- list all tags for ubuntu:
dockertags ubuntu
- list all php tags containing apache:
dockertags php apache
HELP
fi
image="$1"
tags=`wget -q https://registry.hub.docker.com/v1/repositories/${image}/tags -O - | sed -e 's/[][]//g' -e 's/"//g' -e 's/ //g' | tr '}' '\n' | awk -F: '{print $3}'`
if [ -n "$2" ]
then
tags=` echo "${tags}" | grep "$2" `
fi
if [ -n "$3" ]
then
tags=` echo "${tags}" | grep "$3" `
fi
if [ -n "$4" ]
then
tags=` echo "${tags}" | grep "$4" `
fi
echo "${tags}"
}
# To list the architecture of the containers
# src: https://stackoverflow.com/questions/66834864/how-to-determine-when-docker-containers-on-an-m1-macbook-are-running-via-qemu
alias docker-arch-ps='for i in `docker ps --format "{{.Image}}"` ; do docker image inspect $i --format "$i -> {{.Architecture}} : {{.Os}}" ;done';
###################################################################################
# AWS ECR tools
###################################################################################
function delete-aws-ecr-untagged-images() {
aws ecr describe-repositories \
| jq --raw-output '.repositories[].repositoryName' \
| while read repo; do
imageIds=$(aws ecr list-images --repository-name $repo --filter tagStatus=UNTAGGED --query 'imageIds[*]' --output json | jq -r '[.[].imageDigest] | map("imageDigest="+.) | join (" ")');
if [[ "$imageIds" == "" ]]; then continue; fi
echo "aws ecr batch-delete-image --repository-name $repo --image-ids $imageIds";
done
}