General housekeeping tasks
This commit is contained in:
parent
d1fe086f7c
commit
9f1181ae02
|
@ -1,3 +1,4 @@
|
||||||
|
{{ if eq .chezmoi.hostname "pqb-laptop" }}
|
||||||
[".local/share/git-on-web/chemacs2"]
|
[".local/share/git-on-web/chemacs2"]
|
||||||
type = "git-repo"
|
type = "git-repo"
|
||||||
url = "https://github.com/plexus/chemacs2.git"
|
url = "https://github.com/plexus/chemacs2.git"
|
||||||
|
@ -14,6 +15,7 @@
|
||||||
url = "https://github.com/doomemacs/doomemacs"
|
url = "https://github.com/doomemacs/doomemacs"
|
||||||
clone.args = ["--depth=1","--branch=develop","--single-branch"]
|
clone.args = ["--depth=1","--branch=develop","--single-branch"]
|
||||||
refreshPeriod = "168h" # 7 days
|
refreshPeriod = "168h" # 7 days
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
# ["my/code/from_web/nerd-fonts"]
|
# ["my/code/from_web/nerd-fonts"]
|
||||||
# type = "git-repo"
|
# type = "git-repo"
|
||||||
|
|
|
@ -2,8 +2,15 @@ if [[ -n "$(which-command direnv)" ]]; then
|
||||||
function _env() {
|
function _env() {
|
||||||
if [[ -z "$_DIRENV_ShowEnvLogic" ]]; then
|
if [[ -z "$_DIRENV_ShowEnvLogic" ]]; then
|
||||||
echo "_DIRENV_ShowEnvLogic is not defined."
|
echo "_DIRENV_ShowEnvLogic is not defined."
|
||||||
else
|
if [[ $# -gt 0 ]]; then
|
||||||
eval "$_DIRENV_ShowEnvLogic" | LC_ALL=C sort -h
|
local _DIRENV_ShowEnvLogic='printenv'
|
||||||
|
printf "Searching environment for: '${@}'\n\n"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if [[ -n "$_DIRENV_ShowEnvLogic" ]]; then
|
||||||
|
FILTER=''
|
||||||
|
[[ $# -gt 0 ]] && FILTER="| grep ${@}"
|
||||||
|
eval "$_DIRENV_ShowEnvLogic | LC_ALL=C sort -h $FILTER"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -1,21 +1,48 @@
|
||||||
function gcp_project() {
|
function gcp_project() {
|
||||||
gcloud config get-value core/project 2> /dev/null
|
gcloud config get-value core/project 2> /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
function gcp_get_project_id() {
|
function gcp_get_project_id() {
|
||||||
gcloud projects list \
|
gcloud projects list \
|
||||||
--filter="$1" \
|
--filter="$1" \
|
||||||
--format="value(project_id)" \
|
--format="value(project_id)" \
|
||||||
2> /dev/null
|
2> /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
function gcp_get_project_number() {
|
function gcp_get_project_number() {
|
||||||
gcloud projects list \
|
gcloud projects list \
|
||||||
--filter="project_id:$1" \
|
--filter="project_id:$1" \
|
||||||
--format='value(project_number)' \
|
--format='value(project_number)' \
|
||||||
2> /dev/null
|
2> /dev/null
|
||||||
|
}
|
||||||
|
function gcp_get_regions() {
|
||||||
|
gcloud compute regions list --format="value(name)"
|
||||||
}
|
}
|
||||||
|
|
||||||
function gcp_region() {
|
function gcp_get_region_quotas() {
|
||||||
gcloud config get-value compute/region 2> /dev/null
|
region_arr_list=( $(gcloud compute regions list --format="value(name)") )
|
||||||
|
|
||||||
|
for region in ${region_arr_list[@]}; do
|
||||||
|
echo -e $region\\\t$(gcloud compute regions describe $region --format="table(quotas:format='table(metric,limit,usage)')" | grep PREEMPTIBLE_CPUS )
|
||||||
|
done
|
||||||
|
|
||||||
|
#for region in {us-central1,us-east1,us-east4,us-west1,us-west2,us-west3,us-west4}; do
|
||||||
|
# echo -e $region\\\t$(gcloud compute regions describe $region --format="table(quotas:format='table(metric,limit,usage)')" | grep PREEMPTIBLE_CPUS )
|
||||||
|
#done
|
||||||
|
}
|
||||||
|
|
||||||
|
function gcp_get_stack() {
|
||||||
|
local _cmd=$(printf 'N="%s"; CLOUDSDK_ACTIVE_CONFIG_NAME=dust-personal; echo $N; ' $1)
|
||||||
|
_cmd+='{ echo "Instances"; gcloud compute instances list --filter="name:$N"; } '
|
||||||
|
_cmd+='&& { echo "Networks"; gcloud compute networks list --filter="name:$N"; } '
|
||||||
|
_cmd+='&& {gcloud compute networks subnets list --filter="name:$N"} '
|
||||||
|
_cmd+='&& {gcloud compute disks list --filter="name:$N"}'
|
||||||
|
_cmd='{ }'
|
||||||
|
[ $# -ge 2 ] && _cmd="watch -n${2} '$_cmd'"
|
||||||
|
echo $_cmd
|
||||||
|
}
|
||||||
|
# printf '\n\n'; gcp_get_stack 'dragonheart' 5
|
||||||
|
|
||||||
|
function gcp_region() {
|
||||||
|
gcloud config get-value compute/region 2> /dev/null
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,40 @@ if [[ -x $TERRAFORM_BIN ]]; then
|
||||||
sed --unbuffered '/^===FULLSTOP===$/q' | sed --unbuffered '/^===FULLSTOP===$/d'
|
sed --unbuffered '/^===FULLSTOP===$/q' | sed --unbuffered '/^===FULLSTOP===$/d'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _tfless() {
|
||||||
|
local _TF_LOG_FILE=${1-_logs/0_0_lastrun.log}
|
||||||
|
[[ "$1" == "-" ]] && _TF_LOG_FILE='_logs/0_0_lastrun.log'
|
||||||
|
[[ -z "$SZ_DEBUG" ]] || echo "_tfless: ${@} | LESS_NO_WAIT = '${LESS_NO_WAIT}'"
|
||||||
|
[[ "$1" == "-" ]] && {
|
||||||
|
[[ -z "$SZ_DEBUG" ]] || echo "tailing..."
|
||||||
|
trap : INT;
|
||||||
|
tail -f $_TF_LOG_FILE | _tfsedFullStop;
|
||||||
|
} \
|
||||||
|
|| { [[ -z "${LESS_NO_WAIT}" ]] \
|
||||||
|
&& {
|
||||||
|
[[ -z "$SZ_DEBUG" ]] || echo "Invoking less..."
|
||||||
|
less \
|
||||||
|
--no-init \
|
||||||
|
--raw-control-chars \
|
||||||
|
--line-numbers \
|
||||||
|
--quiet \
|
||||||
|
--hilite-unread \
|
||||||
|
--incsearch \
|
||||||
|
--ignore-case \
|
||||||
|
--force \
|
||||||
|
"${@:2}" -- \
|
||||||
|
"$_TF_LOG_FILE"
|
||||||
|
#\
|
||||||
|
#'+G?([^\w\W][\[0-9m+])Plan:' \
|
||||||
|
#'+3k'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function _tfSetLogTS() {
|
||||||
|
export TF_LOG_TS=$(date -d "today" +"%Y%m%d%H%M%S")
|
||||||
|
}
|
||||||
|
|
||||||
function tf() {
|
function tf() {
|
||||||
[[ -z "$TF_LOG_TS" ]] && _tfSetLogTS
|
[[ -z "$TF_LOG_TS" ]] && _tfSetLogTS
|
||||||
local NAME=$1
|
local NAME=$1
|
||||||
|
@ -31,10 +65,10 @@ if [[ -x $TERRAFORM_BIN ]]; then
|
||||||
echo "===FULLSTOP===" >> _logs/0_0_lastrun.log
|
echo "===FULLSTOP===" >> _logs/0_0_lastrun.log
|
||||||
} &
|
} &
|
||||||
|
|
||||||
_tfless _logs/0_0_lastrun.log
|
_tfless -
|
||||||
}
|
}
|
||||||
|
|
||||||
function tfp() {
|
function tf-plan() {
|
||||||
[[ -z "$SZ_DEBUG" ]] || echo "DEBUG: tfplan ${@}"
|
[[ -z "$SZ_DEBUG" ]] || echo "DEBUG: tfplan ${@}"
|
||||||
local _TF_TARGET=""
|
local _TF_TARGET=""
|
||||||
[[ ${#TF_TARGET} -gt 0 ]] && _TF_TARGET="$(printf -- '--target=%s ' ${TF_TARGET[@]})"
|
[[ ${#TF_TARGET} -gt 0 ]] && _TF_TARGET="$(printf -- '--target=%s ' ${TF_TARGET[@]})"
|
||||||
|
@ -43,42 +77,36 @@ if [[ -x $TERRAFORM_BIN ]]; then
|
||||||
tf plan ${_TF_TARGET} "${@}"
|
tf plan ${_TF_TARGET} "${@}"
|
||||||
}
|
}
|
||||||
|
|
||||||
function _tfless() {
|
function get-tf-env() {
|
||||||
local _TF_LOG_FILE=${1-_logs/0_0_lastrun.log}
|
local PATTERN="${1-}"
|
||||||
[[ -z "$SZ_DEBUG" ]] || echo "_tfless: ${@} | LESS_NO_WAIT = '${LESS_NO_WAIT}'"
|
compgen -v | grep "^TF_${PATTERN}"
|
||||||
[[ -n "$1" ]] && {
|
}
|
||||||
trap : INT;
|
|
||||||
tail -f $_TF_LOG_FILE | _tfsedFullStop;
|
function clear-tf-env() {
|
||||||
} \
|
local PATTERN="${1}"
|
||||||
|| { [[ -z "${LESS_NO_WAIT}" ]] \
|
local TOCLEAR=$(get-tf-env "${PATTERN}")
|
||||||
&& { less \
|
[[ -z "$TOCLEAR" ]] && {
|
||||||
--no-init \
|
echo "Could not find environment variables matching: $(echo "^TF_${PATTERN}")"
|
||||||
--raw-control-chars \
|
} || {
|
||||||
--line-numbers \
|
unset $TOCLEAR
|
||||||
--quiet \
|
echo "Cleared the following vars: $TOCLEAR"
|
||||||
--hilite-unread \
|
|
||||||
--incsearch \
|
|
||||||
--ignore-case \
|
|
||||||
--force \
|
|
||||||
"${@:2}" -- \
|
|
||||||
"$_TF_LOG_FILE"
|
|
||||||
#\
|
|
||||||
#'+G?([^\w\W][\[0-9m+])Plan:' \
|
|
||||||
#'+3k'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function _tfSetLogTS() {
|
function clear-tf-env-vars() {
|
||||||
export TF_LOG_TS=$(date -d "today" +"%Y%m%d%H%M%S")
|
clear-tf-env 'VAR_[a-z]'
|
||||||
}
|
}
|
||||||
|
|
||||||
function tfinit() {
|
function clear-tf-env-targets() {
|
||||||
return 0
|
clear-tf-env '[A-Z_]*TARGET$'
|
||||||
}
|
}
|
||||||
|
|
||||||
function tfplan() {
|
alias tf-plan-destroy='tf-plan --destroy '
|
||||||
return 0
|
alias tf-apply='tf apply '
|
||||||
}
|
|
||||||
|
alias tfp='tf-plan '
|
||||||
|
alias tfpd='tf-plan-destroy '
|
||||||
|
alias tfa='tf-apply '
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
if [[ -n "$(type -fP direnv)" ]]; then
|
||||||
|
source <( direnv hook bash )
|
||||||
|
source <( direnv stdlib )
|
||||||
|
fi
|
|
@ -1 +1 @@
|
||||||
[[ -n "$(type -fP gcloud)" ]] && source <(oh-my-posh completion bash)
|
[[ -n "$(which-command oh-my-posh)" ]] && source <(oh-my-posh completion bash)
|
||||||
|
|
Loading…
Reference in New Issue