This commit is contained in:
Daniel Flanagan 2020-02-10 21:25:23 -06:00
parent 16de6fba1d
commit 1024a3626b
Signed by: lytedev
GPG key ID: 5B2020A0F9921EF4
5 changed files with 54 additions and 6 deletions

View file

@ -14,7 +14,7 @@
[core]
editor = nvim
pager = less -r
pager = diff-so-fancy | less --tabs=2 -RFX
[http "https://gopkg.in"]
followRedirects = true
@ -63,3 +63,17 @@
[gpg]
program = gpg2
[color]
ui = true
[color "diff-highlight"]
oldNormal = red bold
oldHighlight = red bold 52
newNormal = green bold
newHighlight = green bold 22
[color "diff"]
meta = 11
frag = magenta bold
commit = yellow bold
old = red bold
new = green bold
whitespace = red reverse

8
bin/k8s-yaml-diff Executable file
View file

@ -0,0 +1,8 @@
#!/usr/bin/env bash
[ "$#" -lt 2 ] && echo "Need two filenames." && exit 1
f1="$1"; shift
f2="$1"; shift
nvim -d <(k8s-yaml-sort "$f1") <(k8s-yaml-sort "$f2")

17
bin/k8s-yaml-sort Executable file
View file

@ -0,0 +1,17 @@
#!/usr/bin/env bash
[ "$#" -lt 1 ] && echo "Need a filename." && exit 1
cat "$1" | yq -s . | jq -S '
sort_by(.metadata.name) |
sort_by(.kind) |
.[] | .spec.template.spec.containers |=
if . == null then empty
else
map(
if . == null then empty
else .env |= sort_by(.name)
| .volumeMounts |= sort_by(.name)
end
)
end
'

View file

@ -52,19 +52,20 @@ else
trap "${cleanup_trap}; kill \"$watcher\"" EXIT
fi
job="call jobstart(['inotifywait', '-m', '-e', 'close_write', '${out}'], {'on_stdout':{j,d,e->execute('checktime')}})"
job="$(echo "let g:pipeline_job_id = jobstart(['inotifywait', '-m', '-e', 'close_write', '${out}'], {'detach':1,'on_stdout':{j,d,e->execute('checktime')}})")"
echo $job >> "$log"
# this will only autosave (and therefore autoreload) for the out buffer (since
# it was opened last) - autosaving (and therefore autorunning) is potentially
# very scary
nvim \
--cmd 'set shm+=atIWF' \
--cmd 'set shm-=Oo' \
nvim -V9"$td/vimlog" \
-o "$in" "$transform" "$out" \
--cmd 'set autoread' \
--cmd 'set updatetime=250' \
--cmd 'autocmd CursorHold,CursorHoldI <buffer> silent write' \
--cmd "$(<<< "$job" tr "'" '"')"
--cmd 'autocmd VimLeave call jobstop(g:pipeline_job_id)' \
--cmd "$job"
#!/usr/bin/env bash

8
bin/yamldiff Executable file
View file

@ -0,0 +1,8 @@
#!/usr/bin/env bash
[ "$#" -lt 2 ] && echo "Need two filenames." && exit 1
f1="$1"; shift; echo "$f1" >&2
f2="$1"; shift; echo "$f2" >&2
nvim -d <(yq . "$f1" | jq -S .) <(yq . "$f2" | jq -S .)