-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathjq.aliases
43 lines (36 loc) · 1.05 KB
/
jq.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
# --unbufferred so tail works
alias tailvice='tail -c +0 -f ~/Library/Application\ Support/Vice/vice.slog'
jqcallsign() {
jq -c --unbuffered --arg cs $1 'select(.callsign == $cs or .aircraft.Callsign == $cs)'
}
jqnav() {
jq -c --unbuffered 'select(.msg == "nav_update") | .flight_state'
}
jqtidy() {
jq --unbuffered 'del(.callstack,.callsign,.time)'
}
jqerr() {
jq -c --unbuffered 'select(.level == "ERROR")'
}
jqdeepdiffac() {
jq -c --unbuffered 'def deepdiff($a; $b):
if $a == $b then
empty
elif (($a | type) == "object" and ($b | type) == "object") then
reduce (($a | keys) + ($b | keys) | unique[]) as $key ({};
.[$key] |= deepdiff($a[$key]; $b[$key])
)
else
[$a, $b]
end;
if deepdiff(.prepost_aircraft[0]; .prepost_aircraft[1]) != {} then
{ "callsign": .callsign,
"command": .callstack | map(select(.function == (.function | ltrimstr("(*Sim).dispatch")))) | first.function,
"diffs": deepdiff(.prepost_aircraft[0]; .prepost_aircraft[1]),
"radio": .radio_transmissions
}
else
empty
end
'
}