Loading .bashrc +102 −102 Original line number Diff line number Diff line Loading @@ -146,54 +146,26 @@ alias wb="ssh -t workbench.shore.co.il 'if tmux ls >/dev/null 2>&1; then tmux a; alias wifi-portal='curl --silent --fail --write-out "%{redirect_url}" --output /dev/null http://detectportal.firefox.com/success.txt' alias xargs="xargs " tfp () { workspace="$(terraform workspace show)" if [ "$workspace" = "default" ] || [ ! -f "$workspace.tfvars" ] then terraform plan -out tfplan "$@" else terraform plan -out tfplan -var-file "$workspace.tfvars" "$@" fi } tfaa () { workspace="$(terraform workspace show)" if [ "$workspace" = "default" ] || [ ! -f "$workspace.tfvars" ] then terraform apply -auto-approve "$@" else terraform apply -auto-approve -var-file "$workspace.tfvars" "$@" fi blue () { printf '\e[1;94m' || true echo "$@" printf '\e[0m' || true } tfr () { workspace="$(terraform workspace show)" if [ "$workspace" = "default" ] || [ ! -f "$workspace.tfvars" ] then terraform refresh "$@" else terraform refresh -var-file "$workspace.tfvars" "$@" fi bold () { printf '\e[1m' || true echo "$@" printf '\e[0m' || true } tfi () { workspace="$(terraform workspace show)" if [ "$workspace" = "default" ] || [ ! -f "$workspace.tfvars" ] then terraform import "$@" else terraform import -var-file "$workspace.tfvars" "$@" fi cyan () { printf '\e[1;96m' || true echo "$@" printf '\e[0m' || true } tfv () { workspace="$(terraform workspace show)" if [ "$workspace" = "default" ] || [ ! -f "$workspace.tfvars" ] then terraform validate "$@" else terraform validate -var-file "$workspace.tfvars" "$@" fi ddg () { w3m "https://duckduckgo.com/lite/?q=$(echo "$@" | urlencode)" } genpass () { Loading @@ -202,6 +174,17 @@ genpass () { echo } gen_csr () { name="${1:-site}" openssl req -new -newkey rsa:4096 -nodes -out "$name.csr" -keyout "$name.key" } green () { printf '\e[1;92m' || true echo "$@" printf '\e[0m' || true } jt () { if command -v pygmentize > /dev/null then Loading @@ -211,44 +194,40 @@ jt () { fi } bold () { printf '\e[1m' || true echo "$@" printf '\e[0m' || true } red () { printf '\e[1;91m' || true echo "$@" printf '\e[0m' || true } green () { printf '\e[1;92m' || true echo "$@" printf '\e[0m' || true } yellow () { printf '\e[1;93m' || true magenta () { printf '\e[1;95m' || true echo "$@" printf '\e[0m' || true } blue () { printf '\e[1;94m' || true echo "$@" printf '\e[0m' || true match_ssl_pair () { if [ "$#" -ne 2 ] then echo "Usage: match_ssl_pair private_key certificate" return 1 fi tempkey="$(mktemp)" tempcert="$(mktemp)" openssl pkey -pubout -outform PEM -in "$1" > "$tempkey" openssl x509 -pubkey -noout -in "$2" > "$tempcert" cmp "$tempkey" "$tempcert" > /dev/null exitcode="$?" rm "$tempkey" "$tempcert" return "$exitcode" } magenta () { printf '\e[1;95m' || true echo "$@" printf '\e[0m' || true # shellcheck disable=SC2120 prune_ssh_sockets () { { [ "${1:-}" != '-f' ] && [ "${1:-}" != '--force' ]; } || killall -v ssh || true find ~/.ssh/ \ -maxdepth 1 \ -type s \ \! -name 'cm_*.sock' \ -execdir sh -c 'lsof -t "$1" >/dev/null || rm "$1"' _ {} \; } cyan () { printf '\e[1;96m' || true red () { printf '\e[1;91m' || true echo "$@" printf '\e[0m' || true } Loading @@ -258,11 +237,6 @@ ssh_keyscan_add () { sort -uo "$HOME/.ssh/known_hosts" "$HOME/.ssh/known_hosts" } gen_csr () { name="${1:-site}" openssl req -new -newkey rsa:4096 -nodes -out "$name.csr" -keyout "$name.key" } sync_comics () { local this_month last_month format format='+kodi.shore.co.il:/srv/library/Comics/0-Day\ Week\ of\ %Y.%m.*' Loading @@ -278,39 +252,65 @@ sync_podcasts () ( unison podcasts ) ddg () { w3m "https://duckduckgo.com/lite/?q=$(echo "$@" | urlencode)" tfaa () { workspace="$(terraform workspace show)" if [ "$workspace" = "default" ] || [ ! -f "$workspace.tfvars" ] then terraform apply -auto-approve "$@" else terraform apply -auto-approve -var-file "$workspace.tfvars" "$@" fi } toux () { touch "$@" chmod +x "$@" tfi () { workspace="$(terraform workspace show)" if [ "$workspace" = "default" ] || [ ! -f "$workspace.tfvars" ] then terraform import "$@" else terraform import -var-file "$workspace.tfvars" "$@" fi } match_ssl_pair () { if [ "$#" -ne 2 ] tfp () { workspace="$(terraform workspace show)" if [ "$workspace" = "default" ] || [ ! -f "$workspace.tfvars" ] then echo "Usage: match_ssl_pair private_key certificate" return 1 terraform plan -out tfplan "$@" else terraform plan -out tfplan -var-file "$workspace.tfvars" "$@" fi tempkey="$(mktemp)" tempcert="$(mktemp)" openssl pkey -pubout -outform PEM -in "$1" > "$tempkey" openssl x509 -pubkey -noout -in "$2" > "$tempcert" cmp "$tempkey" "$tempcert" > /dev/null exitcode="$?" rm "$tempkey" "$tempcert" return "$exitcode" } # shellcheck disable=SC2120 prune_ssh_sockets () { { [ "${1:-}" != '-f' ] && [ "${1:-}" != '--force' ]; } || killall -v ssh || true find ~/.ssh/ \ -maxdepth 1 \ -type s \ \! -name 'cm_*.sock' \ -execdir sh -c 'lsof -t "$1" >/dev/null || rm "$1"' _ {} \; tfr () { workspace="$(terraform workspace show)" if [ "$workspace" = "default" ] || [ ! -f "$workspace.tfvars" ] then terraform refresh "$@" else terraform refresh -var-file "$workspace.tfvars" "$@" fi } tfv () { workspace="$(terraform workspace show)" if [ "$workspace" = "default" ] || [ ! -f "$workspace.tfvars" ] then terraform validate "$@" else terraform validate -var-file "$workspace.tfvars" "$@" fi } toux () { touch "$@" chmod +x "$@" } yellow () { printf '\e[1;93m' || true echo "$@" printf '\e[0m' || true } __prompt () { Loading Loading
.bashrc +102 −102 Original line number Diff line number Diff line Loading @@ -146,54 +146,26 @@ alias wb="ssh -t workbench.shore.co.il 'if tmux ls >/dev/null 2>&1; then tmux a; alias wifi-portal='curl --silent --fail --write-out "%{redirect_url}" --output /dev/null http://detectportal.firefox.com/success.txt' alias xargs="xargs " tfp () { workspace="$(terraform workspace show)" if [ "$workspace" = "default" ] || [ ! -f "$workspace.tfvars" ] then terraform plan -out tfplan "$@" else terraform plan -out tfplan -var-file "$workspace.tfvars" "$@" fi } tfaa () { workspace="$(terraform workspace show)" if [ "$workspace" = "default" ] || [ ! -f "$workspace.tfvars" ] then terraform apply -auto-approve "$@" else terraform apply -auto-approve -var-file "$workspace.tfvars" "$@" fi blue () { printf '\e[1;94m' || true echo "$@" printf '\e[0m' || true } tfr () { workspace="$(terraform workspace show)" if [ "$workspace" = "default" ] || [ ! -f "$workspace.tfvars" ] then terraform refresh "$@" else terraform refresh -var-file "$workspace.tfvars" "$@" fi bold () { printf '\e[1m' || true echo "$@" printf '\e[0m' || true } tfi () { workspace="$(terraform workspace show)" if [ "$workspace" = "default" ] || [ ! -f "$workspace.tfvars" ] then terraform import "$@" else terraform import -var-file "$workspace.tfvars" "$@" fi cyan () { printf '\e[1;96m' || true echo "$@" printf '\e[0m' || true } tfv () { workspace="$(terraform workspace show)" if [ "$workspace" = "default" ] || [ ! -f "$workspace.tfvars" ] then terraform validate "$@" else terraform validate -var-file "$workspace.tfvars" "$@" fi ddg () { w3m "https://duckduckgo.com/lite/?q=$(echo "$@" | urlencode)" } genpass () { Loading @@ -202,6 +174,17 @@ genpass () { echo } gen_csr () { name="${1:-site}" openssl req -new -newkey rsa:4096 -nodes -out "$name.csr" -keyout "$name.key" } green () { printf '\e[1;92m' || true echo "$@" printf '\e[0m' || true } jt () { if command -v pygmentize > /dev/null then Loading @@ -211,44 +194,40 @@ jt () { fi } bold () { printf '\e[1m' || true echo "$@" printf '\e[0m' || true } red () { printf '\e[1;91m' || true echo "$@" printf '\e[0m' || true } green () { printf '\e[1;92m' || true echo "$@" printf '\e[0m' || true } yellow () { printf '\e[1;93m' || true magenta () { printf '\e[1;95m' || true echo "$@" printf '\e[0m' || true } blue () { printf '\e[1;94m' || true echo "$@" printf '\e[0m' || true match_ssl_pair () { if [ "$#" -ne 2 ] then echo "Usage: match_ssl_pair private_key certificate" return 1 fi tempkey="$(mktemp)" tempcert="$(mktemp)" openssl pkey -pubout -outform PEM -in "$1" > "$tempkey" openssl x509 -pubkey -noout -in "$2" > "$tempcert" cmp "$tempkey" "$tempcert" > /dev/null exitcode="$?" rm "$tempkey" "$tempcert" return "$exitcode" } magenta () { printf '\e[1;95m' || true echo "$@" printf '\e[0m' || true # shellcheck disable=SC2120 prune_ssh_sockets () { { [ "${1:-}" != '-f' ] && [ "${1:-}" != '--force' ]; } || killall -v ssh || true find ~/.ssh/ \ -maxdepth 1 \ -type s \ \! -name 'cm_*.sock' \ -execdir sh -c 'lsof -t "$1" >/dev/null || rm "$1"' _ {} \; } cyan () { printf '\e[1;96m' || true red () { printf '\e[1;91m' || true echo "$@" printf '\e[0m' || true } Loading @@ -258,11 +237,6 @@ ssh_keyscan_add () { sort -uo "$HOME/.ssh/known_hosts" "$HOME/.ssh/known_hosts" } gen_csr () { name="${1:-site}" openssl req -new -newkey rsa:4096 -nodes -out "$name.csr" -keyout "$name.key" } sync_comics () { local this_month last_month format format='+kodi.shore.co.il:/srv/library/Comics/0-Day\ Week\ of\ %Y.%m.*' Loading @@ -278,39 +252,65 @@ sync_podcasts () ( unison podcasts ) ddg () { w3m "https://duckduckgo.com/lite/?q=$(echo "$@" | urlencode)" tfaa () { workspace="$(terraform workspace show)" if [ "$workspace" = "default" ] || [ ! -f "$workspace.tfvars" ] then terraform apply -auto-approve "$@" else terraform apply -auto-approve -var-file "$workspace.tfvars" "$@" fi } toux () { touch "$@" chmod +x "$@" tfi () { workspace="$(terraform workspace show)" if [ "$workspace" = "default" ] || [ ! -f "$workspace.tfvars" ] then terraform import "$@" else terraform import -var-file "$workspace.tfvars" "$@" fi } match_ssl_pair () { if [ "$#" -ne 2 ] tfp () { workspace="$(terraform workspace show)" if [ "$workspace" = "default" ] || [ ! -f "$workspace.tfvars" ] then echo "Usage: match_ssl_pair private_key certificate" return 1 terraform plan -out tfplan "$@" else terraform plan -out tfplan -var-file "$workspace.tfvars" "$@" fi tempkey="$(mktemp)" tempcert="$(mktemp)" openssl pkey -pubout -outform PEM -in "$1" > "$tempkey" openssl x509 -pubkey -noout -in "$2" > "$tempcert" cmp "$tempkey" "$tempcert" > /dev/null exitcode="$?" rm "$tempkey" "$tempcert" return "$exitcode" } # shellcheck disable=SC2120 prune_ssh_sockets () { { [ "${1:-}" != '-f' ] && [ "${1:-}" != '--force' ]; } || killall -v ssh || true find ~/.ssh/ \ -maxdepth 1 \ -type s \ \! -name 'cm_*.sock' \ -execdir sh -c 'lsof -t "$1" >/dev/null || rm "$1"' _ {} \; tfr () { workspace="$(terraform workspace show)" if [ "$workspace" = "default" ] || [ ! -f "$workspace.tfvars" ] then terraform refresh "$@" else terraform refresh -var-file "$workspace.tfvars" "$@" fi } tfv () { workspace="$(terraform workspace show)" if [ "$workspace" = "default" ] || [ ! -f "$workspace.tfvars" ] then terraform validate "$@" else terraform validate -var-file "$workspace.tfvars" "$@" fi } toux () { touch "$@" chmod +x "$@" } yellow () { printf '\e[1;93m' || true echo "$@" printf '\e[0m' || true } __prompt () { Loading