work setup sync
This commit is contained in:
@@ -7,14 +7,13 @@ alias tmux_secondary_win='tmux new-session -t main -s secondary'
|
||||
# enable color support of ls and also add handy aliases
|
||||
alias ls='ls --color=auto'
|
||||
alias grep='grep --color=auto'
|
||||
alias fgrep='fgrep --color=auto'
|
||||
alias egrep='egrep --color=auto'
|
||||
alias fgrep='grep -F --color=auto'
|
||||
alias egrep='grep -E --color=auto'
|
||||
|
||||
alias docker=podman
|
||||
|
||||
alias d='dirs -v'
|
||||
# shfmt needs to ignore this because it is a zsh specific syntax
|
||||
# shfmt:ignore:start
|
||||
for index ({1..9}) alias "c$index"="cd +${index}"; unset index
|
||||
# shfmt:ignore:end
|
||||
for index in 1 2 3 4 5 6 7 8 9; do alias "c$index"="cd +${index}"; done; unset index
|
||||
|
||||
alias kpget="keepassxc-cli show -a Password ${KEEPASS_DB}"
|
||||
alias kptotp="keepassxc-cli show -t ${KEEPASS_DB}"
|
||||
@@ -26,7 +25,7 @@ _KP_KEYCHAIN_SVC="keepassxc-cli-cache"
|
||||
_KP_KEYCHAIN_ACCT="master-password"
|
||||
|
||||
_kp_pw_store() {
|
||||
case "$(uname -s)" in
|
||||
case "$UNAME_STRING" in
|
||||
Darwin)
|
||||
security add-generic-password -U \
|
||||
-s "$_KP_KEYCHAIN_SVC" -a "$_KP_KEYCHAIN_ACCT" -w "$1"
|
||||
@@ -39,7 +38,7 @@ _kp_pw_store() {
|
||||
}
|
||||
|
||||
_kp_pw_get() {
|
||||
case "$(uname -s)" in
|
||||
case "$UNAME_STRING" in
|
||||
Darwin)
|
||||
security find-generic-password \
|
||||
-s "$_KP_KEYCHAIN_SVC" -a "$_KP_KEYCHAIN_ACCT" -w 2>/dev/null
|
||||
@@ -52,7 +51,7 @@ _kp_pw_get() {
|
||||
}
|
||||
|
||||
_kp_pw_clear() {
|
||||
case "$(uname -s)" in
|
||||
case "$UNAME_STRING" in
|
||||
Darwin)
|
||||
security delete-generic-password \
|
||||
-s "$_KP_KEYCHAIN_SVC" -a "$_KP_KEYCHAIN_ACCT" &>/dev/null
|
||||
@@ -87,12 +86,30 @@ function load_gemini() {
|
||||
}
|
||||
|
||||
function totp() {
|
||||
local clip=false
|
||||
[[ "$1" == "-c" ]] && clip=true && shift
|
||||
|
||||
local code
|
||||
case "$1" in
|
||||
hcf) kptotps "personal/Dev/AWS Console" ;;
|
||||
aws) kptotps "work/Own/AWS console" ;;
|
||||
pci) kptotps "work/Own/PCI/AWS Workspaces" ;;
|
||||
*) echo "Usage: totp {hcf|aws|pci}" >&2; return 1 ;;
|
||||
hcf) code=$(kptotps "personal/Dev/AWS Console") ;;
|
||||
aws) code=$(kptotps "work/Own/AWS console") ;;
|
||||
pci) code=$(kptotps "work/Own/PCI/AWS Workspaces") ;;
|
||||
*) echo "Usage: totp [-c] {hcf|aws|pci}" >&2; return 1 ;;
|
||||
esac
|
||||
|
||||
echo "$code"
|
||||
if $clip; then
|
||||
case "$UNAME_STRING" in
|
||||
Darwin) echo -n "$code" | pbcopy ;;
|
||||
Linux) if [[ "$XDG_SESSION_TYPE" == "wayland" ]]; then
|
||||
echo -n "$code" | wl-copy
|
||||
else
|
||||
echo -n "$code" | xclip -selection clipboard
|
||||
fi ;;
|
||||
|
||||
esac
|
||||
echo "(copied to clipboard)"
|
||||
fi
|
||||
}
|
||||
|
||||
_get_aws_config_path() {
|
||||
@@ -147,16 +164,23 @@ _awsume_cmd() {
|
||||
|
||||
alias asm="_awsume_cmd"
|
||||
|
||||
alias tf="terraform"
|
||||
alias tfi="tf init"
|
||||
alias tfp="tf plan -lock=false"
|
||||
alias tfa="tf apply"
|
||||
alias tfu="tf get -update"
|
||||
alias tg="terragrunt"
|
||||
alias tgi="tg init"
|
||||
alias tgp="tg plan -lock=false"
|
||||
alias tga="tg apply"
|
||||
alias tgu="tg get -update"
|
||||
_ensure_awsume() {
|
||||
if [[ -z "$AWSUME_PROFILE" ]]; then
|
||||
echo "No awsume session found. Starting one..."
|
||||
_awsume_cmd || return 1
|
||||
fi
|
||||
}
|
||||
|
||||
tf() { _ensure_awsume && terraform "$@"; }
|
||||
tfi() { _ensure_awsume && terraform init "$@"; }
|
||||
tfp() { _ensure_awsume && terraform plan -lock=false "$@"; }
|
||||
tfa() { _ensure_awsume && terraform apply "$@"; }
|
||||
tfu() { _ensure_awsume && terraform get -update "$@"; }
|
||||
tg() { _ensure_awsume && terragrunt "$@"; }
|
||||
tgi() { _ensure_awsume && terragrunt init "$@"; }
|
||||
tgp() { _ensure_awsume && terragrunt plan -lock=false "$@"; }
|
||||
tga() { _ensure_awsume && terragrunt apply "$@"; }
|
||||
tgu() { _ensure_awsume && terragrunt get -update "$@"; }
|
||||
|
||||
alias curltime="curl -w \"@$HOME/.curl-format.txt\" -o /dev/null -s "
|
||||
|
||||
@@ -196,7 +220,7 @@ git_push() {
|
||||
local branch
|
||||
branch=$(git branch --show-current)
|
||||
|
||||
git push origin "$branch" $@
|
||||
git push origin "$branch" "$@"
|
||||
}
|
||||
|
||||
alias gpush="git_push"
|
||||
@@ -204,7 +228,7 @@ alias gpush="git_push"
|
||||
passgen() {
|
||||
length=${1:-"12"}
|
||||
if [[ "$length" == <-> ]]; then
|
||||
echo $(cat /dev/urandom| base64 | head -c "$length")
|
||||
echo $(cat /dev/urandom| base64 -w0 | head -c "$length")
|
||||
else
|
||||
echo "passgen() takes a positive integer as first argument"
|
||||
echo "got $length"
|
||||
|
||||
Reference in New Issue
Block a user