-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshelpers
59 lines (47 loc) · 1.78 KB
/
shelpers
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
#!/bin/bash
############################## aliases ##############################
alias csvtojson='jq -R -s '\''
split("\n") |
.[0:1] as $headers |
.[1:-1] |
map(
select(length > 0) |
split(",") as $row |
[range(0; $headers[0]|split(",")|length)] as $i |
reduce $i[] as $ix ({};
. + {($headers[0]|split(",")[$ix]): $row[$ix]}
)
)
'\'''
alias files-intersection='comm -12'
alias files-difference='comm -23'
# Usage examples of files-* aliases:
# files-intersection <(sort file1.txt) <(sort file2.txt)
# files-difference <(sort file1.txt) <(sort file2.txt)
############################## functions ##############################
scpfrom() {
scp -ri ${HOME}/cloud-dev-server.pem ec2-user@${EC2_DEV_MACHINE_IP}:${1} ${2}
}
scpto() {
scp -ri ${HOME}/cloud-dev-server.pem ${1} ec2-user@${EC2_DEV_MACHINE_IP}:${2}
}
# one time syncing of a local directory content to the cloud dev machine
sync() {
rsync -avz -e "ssh -i ~${HOME}/cloud-dev-server.pem" -r ${1} ec2-user@${EC2_DEV_MACHINE_IP}:${2}
}
# continuous syncing of a local directory content to the cloud dev machine - useful when actively developing
# IDE's support remote sync OOTB however developing against a local fast copy (eg. on a flight) and syncing with cloud when needed is helpful to me
# usually I run it as "contsync &"
contsync() {
while true; do
# sync /Users/mukesh.choudhari/DevWorkspace /home/ec2-user/workspace
# sync /Users/mukesh.choudhari/GolandProjects /home/ec2-user/workspace
#### <add directories you'd like to keep in sync over here> ####
sleep 5 #### adjust the sync period to your taste ####
done
}
############################## export ##############################
export -f scpfrom >/dev/null
export -f scpto >/dev/null
export -f sync >/dev/null
export -f contsync >/dev/null