create some shell aliases and the _set_secret_and_run
zsh function
This commit is contained in:
parent
852ea3aab7
commit
4d748e1477
1 changed files with 28 additions and 0 deletions
|
@ -43,6 +43,31 @@
|
|||
command "$VISUAL" "''${args[@]}"
|
||||
fi
|
||||
}
|
||||
_set_secret_and_run() {
|
||||
if [[ $# -lt 2 ]]; then
|
||||
echo "Usage: _set_secret_and_run <secret_file> <var_name> <command> [args...]"
|
||||
return 1
|
||||
fi
|
||||
|
||||
local secret_file="$1"
|
||||
local var_name="$2"
|
||||
shift 2
|
||||
|
||||
if [[ ! -f "$secret_file" ]]; then
|
||||
echo "Error: Secret file '$secret_file' not found."
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo "Setting $var_name to secret value from $secret_file"
|
||||
local old_value="''${(P)var_name}"
|
||||
local secret_value=$(<"$secret_file")
|
||||
export $var_name="$secret_value"
|
||||
|
||||
echo "Running command: $@"
|
||||
command "$@"
|
||||
export $var_name="$old_value"
|
||||
}
|
||||
|
||||
|
||||
if (( $+commands[kitten] )); then
|
||||
alias "ssh"="kitten ssh"
|
||||
|
@ -87,6 +112,9 @@
|
|||
e = "edit";
|
||||
c = "clear";
|
||||
sudo = "sudo ";
|
||||
bun = "_set_secret_and_run /run/secrets/npm NPM_CONFIG_TOKEN bun";
|
||||
bunx = "_set_secret_and_run /run/secrets/npm NPM_CONFIG_TOKEN bunx";
|
||||
publish = "_set_secret_and_run /run/secrets/npm NPM_CONFIG_TOKEN bun publish --access public";
|
||||
s = "sudo";
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue