From 06b2c129a40e3090e4492519b072de0efdbcb8f5 Mon Sep 17 00:00:00 2001 From: xeruf <27jf@pm.me> Date: Thu, 28 Apr 2022 17:15:51 +0100 Subject: [PATCH 1/2] config/shell: add stackspin CLI wrapper --- .config/shell/functions | 2 +- .config/shell/server | 41 +++++++++++++++++++++++++++++++++++++++++ .local/bin/scripts/rpl | 2 +- 3 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 .config/shell/server diff --git a/.config/shell/functions b/.config/shell/functions index 4a9aaba..50c6f00 100644 --- a/.config/shell/functions +++ b/.config/shell/functions @@ -4,7 +4,7 @@ if test "$ZSH_NAME" = "zsh" then alias -g ___='"$(eval "$(fc -ln -1)" | tail -n 1)"' alias -g G="| grp" - alias -g X="| xargs -d '\n'" + alias -g X="| xargs -d '\n' -L 1" alias -g X1="| xargs -d '\n' -n 1" alias -g XC="| xclip -selection clipboard" alias -g L="--color=always | ${PAGER:-less}" diff --git a/.config/shell/server b/.config/shell/server new file mode 100644 index 0000000..e3758a0 --- /dev/null +++ b/.config/shell/server @@ -0,0 +1,41 @@ +export STACKSPIN="$HOME/stackspin" +_stackspin_cluster_cache=/var/tmp/stackspin-cluster + +# Stackspin CLI Wrapper +# Initialize once with "stack select example.org", +# then it loads the last selected one on startup. +# Presumes a mapping like the following in your ssh config: +# Host example.org +# Hostname [IP] +stack() { + case "$1" in + (select) shift + export _cluster_name="$1" + export _cluster_ip="$(ssh -G "$_cluster_name" | grep --max-count 1 "^hostname " | cut -d " " -f2-)" + export CLUSTER_DIR="$STACKSPIN/clusters/$_cluster_name" + export KUBECONFIG="$CLUSTER_DIR/kube_config_cluster.yml" + echo Selected "$_cluster_name" with IP "$_cluster_ip" + echo "$_cluster_name" >"$_stackspin_cluster_cache" + ;; + (sso) shift + builtin cd "$STACKSPIN" + kubectl exec -n stackspin $(kubectl get pods -A | grep single-sign-on-login | awk '{print $2}') -- flask "$@";; + (user) + if test "$2" = "init" + then mail="$3" + shift 3 + stack user create "$mail" + stack user update "$mail" name "$*" + echo "Initialized user '$*' with email '$mail'" + else kubectl exec -n stackspin $(kubectl get pods -A | grep single-sign-on-login | awk '{print $2}') -- flask "$@" + fi;; + (*) builtin cd "$STACKSPIN" + if test $# -gt 1 -a "$1" = install + then shift && "./install/install-$1.sh" || ./install/install-app.sh "$@" + else python3 -m stackspin "$_cluster_name" "$@" + fi;; + esac +} +cat "$_stackspin_cluster_cache" 2>/dev/null | + while read cluster; do stack select "$cluster"; done +cd "$HOME/stackspout" diff --git a/.local/bin/scripts/rpl b/.local/bin/scripts/rpl index c9be95c..c73cbe9 100755 --- a/.local/bin/scripts/rpl +++ b/.local/bin/scripts/rpl @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/bash -e # Use grep and sed to replace $1 with $2 recursively and print what is done grep --null --recursive --files-with-matches \ --binary-files=without-match "--exclude-dir={$DIRS_IGNORE}" "$1" "${@:3}" | From 5ba8b28fec4e2c41b90252f6ccbad61fea7f55dc Mon Sep 17 00:00:00 2001 From: xeruf <27jf@pm.me> Date: Fri, 29 Apr 2022 09:46:52 +0200 Subject: [PATCH 2/2] config/espanso/match: create separate pass config --- .config/espanso/match/base.yml | 125 +-------------------------------- .config/espanso/match/pass.yml | 121 +++++++++++++++++++++++++++++++ 2 files changed, 123 insertions(+), 123 deletions(-) create mode 100644 .config/espanso/match/pass.yml diff --git a/.config/espanso/match/base.yml b/.config/espanso/match/base.yml index 92bec58..a6d1d2e 100644 --- a/.config/espanso/match/base.yml +++ b/.config/espanso/match/base.yml @@ -1,7 +1,6 @@ -# Automatically generated by espanso migration tool -# Original file: default.yml - matches: + - trigger: ":see" + replace: "🙈" - trigger: ":grue" replace: |- Grüße, @@ -25,123 +24,3 @@ matches: type: shell params: cmd: "curl 'https://api.ipify.org'" - # Sensitive data through pass - - trigger: ":ep" - replace: "{{output}}" - vars: - - name: output - type: shell - params: - cmd: pass info/email/personal - - trigger: ":ec" - replace: "{{output}}" - vars: - - name: output - type: shell - params: - cmd: pass info/email/church - - trigger: ":eu" - replace: "{{output}}" - vars: - - name: output - type: shell - params: - cmd: pass info/email/uni - - trigger: ":eaur" - replace: "{{output}}" - vars: - - name: output - type: shell - params: - cmd: pass info/email/aur - - trigger: ":a0" - replace: "{{output}}" - vars: - - name: output - type: shell - params: - cmd: pass info/address | head -1 - - trigger: ":a1" - replace: "{{output}}" - vars: - - name: output - type: shell - params: - cmd: pass info/address | head -2 | tail -1 - - trigger: ":as" - replace: "{{output}}" - vars: - - name: output - type: shell - params: - cmd: "pass info/address | head -2 | tail -1 | cut -d' ' -f1" - - trigger: ":a2" - replace: "{{output}}" - vars: - - name: output - type: shell - params: - cmd: pass info/address | tail -1 - - trigger: ":ap" - replace: "{{output}}" - vars: - - name: output - type: shell - params: - cmd: "pass info/address | tail -1 | cut -d' ' -f1" - - trigger: ":ac" - replace: "{{output}}" - vars: - - name: output - type: shell - params: - cmd: "pass info/address | tail -1 | cut -d' ' -f2" - - trigger: ":tel" - replace: "{{output}}" - vars: - - name: output - type: shell - params: - cmd: pass info/phone - - trigger: ":adt" - replace: "{{output}}" - vars: - - name: output - type: shell - params: - cmd: pass info/address-bt - - trigger: ":add" - replace: "{{output}}" - vars: - - name: output - type: shell - params: - cmd: pass info/address - - trigger: ":tax" - replace: "{{output}}" - vars: - - name: output - type: shell - params: - cmd: pass info/tax-id | head -1 - - trigger: ":ss" - replace: "{{output}}" - vars: - - name: output - type: shell - params: - cmd: pass info/social-security | head -1 - - trigger: ":sign" - replace: "{{output}}" - vars: - - name: output - type: shell - params: - cmd: pass info/signature - - trigger: ":iban" - replace: "{{output}}" - vars: - - name: output - type: shell - params: - cmd: pass info/banking/dkb | head -1 diff --git a/.config/espanso/match/pass.yml b/.config/espanso/match/pass.yml new file mode 100644 index 0000000..c160387 --- /dev/null +++ b/.config/espanso/match/pass.yml @@ -0,0 +1,121 @@ +# Sensitive data through pass +matches: + - trigger: ":ep" + replace: "{{output}}" + vars: + - name: output + type: shell + params: + cmd: pass info/email/personal + - trigger: ":ec" + replace: "{{output}}" + vars: + - name: output + type: shell + params: + cmd: pass info/email/church + - trigger: ":eu" + replace: "{{output}}" + vars: + - name: output + type: shell + params: + cmd: pass info/email/uni + - trigger: ":eaur" + replace: "{{output}}" + vars: + - name: output + type: shell + params: + cmd: pass info/email/aur + - trigger: ":a0" + replace: "{{output}}" + vars: + - name: output + type: shell + params: + cmd: pass info/address | head -1 + - trigger: ":a1" + replace: "{{output}}" + vars: + - name: output + type: shell + params: + cmd: pass info/address | head -2 | tail -1 + - trigger: ":as" + replace: "{{output}}" + vars: + - name: output + type: shell + params: + cmd: "pass info/address | head -2 | tail -1 | cut -d' ' -f1" + - trigger: ":a2" + replace: "{{output}}" + vars: + - name: output + type: shell + params: + cmd: pass info/address | tail -1 + - trigger: ":ap" + replace: "{{output}}" + vars: + - name: output + type: shell + params: + cmd: "pass info/address | tail -1 | cut -d' ' -f1" + - trigger: ":ac" + replace: "{{output}}" + vars: + - name: output + type: shell + params: + cmd: "pass info/address | tail -1 | cut -d' ' -f2" + - trigger: ":tel" + replace: "{{output}}" + vars: + - name: output + type: shell + params: + cmd: pass info/phone + - trigger: ":adt" + replace: "{{output}}" + vars: + - name: output + type: shell + params: + cmd: pass info/address-bt + - trigger: ":add" + replace: "{{output}}" + vars: + - name: output + type: shell + params: + cmd: pass info/address + - trigger: ":tax" + replace: "{{output}}" + vars: + - name: output + type: shell + params: + cmd: pass info/tax-id | head -1 + - trigger: ":ss" + replace: "{{output}}" + vars: + - name: output + type: shell + params: + cmd: pass info/social-security | head -1 + - trigger: ":sign" + replace: "{{output}}" + vars: + - name: output + type: shell + params: + cmd: pass info/signature + - trigger: ":iban" + replace: "{{output}}" + vars: + - name: output + type: shell + params: + cmd: pass info/banking/dkb | head -1