diff --git a/apps/git/config b/apps/git/config index 49f172b..6cffd0c 100644 --- a/apps/git/config +++ b/apps/git/config @@ -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 diff --git a/bin/k8s-yaml-diff b/bin/k8s-yaml-diff new file mode 100755 index 0000000..4170390 --- /dev/null +++ b/bin/k8s-yaml-diff @@ -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") diff --git a/bin/k8s-yaml-sort b/bin/k8s-yaml-sort new file mode 100755 index 0000000..ee738a5 --- /dev/null +++ b/bin/k8s-yaml-sort @@ -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 + ' diff --git a/bin/pipeline b/bin/pipeline index 9608c4a..8b354c2 100755 --- a/bin/pipeline +++ b/bin/pipeline @@ -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 silent write' \ - --cmd "$(<<< "$job" tr "'" '"')" + --cmd 'autocmd VimLeave call jobstop(g:pipeline_job_id)' \ + --cmd "$job" #!/usr/bin/env bash diff --git a/bin/yamldiff b/bin/yamldiff new file mode 100755 index 0000000..fdecc6f --- /dev/null +++ b/bin/yamldiff @@ -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 .)