From 187a467092f67386a0c8b313c4c979c15d575b44 Mon Sep 17 00:00:00 2001 From: yage Date: Wed, 11 Jan 2023 17:09:59 -0700 Subject: [PATCH] v2.7.0 ===================================================================== --- New Features ------------------------- - `__override` variables now allow values to be force-overwritten --- zsh/scwrypts/README.md | 8 ++++++++ zsh/utils/environment.zsh | 3 +++ 2 files changed, 11 insertions(+) diff --git a/zsh/scwrypts/README.md b/zsh/scwrypts/README.md index f15c513..d6e3337 100644 --- a/zsh/scwrypts/README.md +++ b/zsh/scwrypts/README.md @@ -50,6 +50,14 @@ Setting the `AWS_REGION` variable will cause scwrypts to ignore the `__select` s CI will fail on select, because CI fails on any FZF prompt. +#### `__override` Environment Variables +Override any variable with the indicated value. +This will take precedence over existing values *and* any other special environment variable types. + +Examples of use: +- temporarily changing a single value in your current session (e.g. `export VARIABLE__override=value`) +- overriding a variable for a one-time command (e.g. `VARIABLE__override=value scwrypts ...`) + ## Logs Quickly view or clear Scwrypts logs. diff --git a/zsh/utils/environment.zsh b/zsh/utils/environment.zsh index 84dde90..8332800 100644 --- a/zsh/utils/environment.zsh +++ b/zsh/utils/environment.zsh @@ -8,6 +8,9 @@ __CHECK_ENV_VAR() { local NAME="$1" [ ! $NAME ] && return 1 + local OVERRIDE_VALUE=$(eval echo '$'$NAME'__override') + [ $OVERRIDE_VALUE ] && export $NAME=$OVERRIDE_VALUE && return 0 + local OPTIONAL="$2" local DEFAULT_VALUE="$3"