mirror of
https://github.com/ivuorinen/dotfiles.git
synced 2026-03-07 12:01:49 +00:00
chore(bin): update x-env-list with skipping
This commit is contained in:
@@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
# Define protected keywords. Values of these keys are displayed as [protected value].
|
# Define protected keywords. Values of these keys are displayed as [protected value].
|
||||||
# The keys are case-insensitive and are matched as substrings.
|
# The keys are case-insensitive and are matched as substrings.
|
||||||
PROTECTED_KEYS=("*TOKEN*" "*SECRET*" "DIRENV_DIFF" "DIRENV_WATCHES" "PATH" "FPATH")
|
PROTECTED_KEYS=("*TOKEN*" "*SECRET*" "DIRENV_DIFF" "DIRENV_WATCHES")
|
||||||
|
|
||||||
# Default grouping is based on the first part before underscore, but can be overridden
|
# Default grouping is based on the first part before underscore, but can be overridden
|
||||||
# either by custom grouping file or by the get_custom_group function.
|
# either by custom grouping file or by the get_custom_group function.
|
||||||
@@ -49,17 +49,50 @@ DEFINED_GROUPS=(
|
|||||||
"PYENV_ROOT=PYTHON"
|
"PYENV_ROOT=PYTHON"
|
||||||
"PYENV_SHELL=PYTHON"
|
"PYENV_SHELL=PYTHON"
|
||||||
"PYTHONPATH=PYTHON"
|
"PYTHONPATH=PYTHON"
|
||||||
|
"POETRY_HOME=PYTHON"
|
||||||
"RUSTUP_HOME=RUST"
|
"RUSTUP_HOME=RUST"
|
||||||
"RUST_WITHOUT=RUST"
|
"RUST_WITHOUT=RUST"
|
||||||
"SHELL=SHELL"
|
"SHELL=SHELL"
|
||||||
"TMPDIR=SHELL"
|
"TMPDIR=SHELL"
|
||||||
"USER=SHELL"
|
"USER=SHELL"
|
||||||
|
"SECURITYSESSIONID=SHELL"
|
||||||
|
"SHLVL=SHELL"
|
||||||
"WORKON_HOME=PYTHON"
|
"WORKON_HOME=PYTHON"
|
||||||
"ZSH=ZSH"
|
"ZSH=ZSH"
|
||||||
|
"LANG=SHELL"
|
||||||
|
"EDITOR=SHELL"
|
||||||
|
"VISUAL=SHELL"
|
||||||
|
"COMMAND_MODE=SHELL"
|
||||||
|
"COLORTERM=SHELL"
|
||||||
|
"CARGO_BIN_HOME=RUST"
|
||||||
|
"CARGO_HOME=RUST"
|
||||||
|
"LaunchInstanceID=SHELL"
|
||||||
|
"SECURITYSESSIONID=SHELL"
|
||||||
|
"TERM=SHELL"
|
||||||
|
"TERM_PROGRAM=SHELL"
|
||||||
|
"TERM_PROGRAM_VERSION=SHELL"
|
||||||
|
"XPC_FLAGS=SHELL"
|
||||||
|
"XPC_SERVICE_NAME=SHELL"
|
||||||
|
"NPM_CONFIG_PREFIX=NODE"
|
||||||
|
"YARN_GLOBAL_FOLDER=NODE"
|
||||||
|
"MASON_HOME=NVIM"
|
||||||
|
"asdf_data_dir=ASDF"
|
||||||
|
"nvm_current_version=NODE"
|
||||||
|
"NVM_NODE_BIN_DIR=NODE"
|
||||||
"_=SHELL"
|
"_=SHELL"
|
||||||
"npm_config_cache=NPM"
|
"npm_config_cache=NPM"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
SKIPPED_KEYS=(
|
||||||
|
"_tide*"
|
||||||
|
"__FISH_*"
|
||||||
|
"___paths_plugin_colors"
|
||||||
|
"__CFBundleIdentifier"
|
||||||
|
"__CF_USER_TEXT_ENCODING"
|
||||||
|
"PATH"
|
||||||
|
"FPATH"
|
||||||
|
)
|
||||||
|
|
||||||
CONFIG_FILE="$X_ENV_GROUPING"
|
CONFIG_FILE="$X_ENV_GROUPING"
|
||||||
|
|
||||||
# If we have configuration file, run extra checks so we can process it.
|
# If we have configuration file, run extra checks so we can process it.
|
||||||
@@ -93,6 +126,12 @@ if [[ -f "$CONFIG_FILE" ]]; then
|
|||||||
PROTECTED_KEYS+=("$key")
|
PROTECTED_KEYS+=("$key")
|
||||||
done <<< "$CUSTOM_KEYS"
|
done <<< "$CUSTOM_KEYS"
|
||||||
|
|
||||||
|
SKIPPED+=("$(yq '.skipped_keys[]' "$CONFIG_FILE")")
|
||||||
|
while IFS= read -r key; do
|
||||||
|
# Add to default_skipped_keys
|
||||||
|
SKIPPED_KEYS+=("$key")
|
||||||
|
done <<< "$SKIPPED"
|
||||||
|
|
||||||
CUSTOM_GROUPS=$(yq '.custom_grouping[]' "$CONFIG_FILE")
|
CUSTOM_GROUPS=$(yq '.custom_grouping[]' "$CONFIG_FILE")
|
||||||
while IFS= read -r group; do
|
while IFS= read -r group; do
|
||||||
group_name=$(echo "$group" | yq 'keys[0]')
|
group_name=$(echo "$group" | yq 'keys[0]')
|
||||||
@@ -150,6 +189,22 @@ get_custom_group()
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
is_skipped()
|
||||||
|
{
|
||||||
|
local key=$1
|
||||||
|
for skipped_key in "${SKIPPED_KEYS[@]}"; do
|
||||||
|
# Direct match
|
||||||
|
if [[ "$key" == "$skipped_key" ]]; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
# Wildcard match (skipped_key contains '*')
|
||||||
|
if [[ "$skipped_key" == *"*"* ]] && [[ "$key" == $skipped_key ]]; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
# Create arrays to store all groups, group data and max lengths for each group
|
# Create arrays to store all groups, group data and max lengths for each group
|
||||||
all_groups=()
|
all_groups=()
|
||||||
group_data=()
|
group_data=()
|
||||||
@@ -157,6 +212,15 @@ group_max_lengths=()
|
|||||||
|
|
||||||
# Get environment variables and group them
|
# Get environment variables and group them
|
||||||
while IFS='=' read -r key value; do
|
while IFS='=' read -r key value; do
|
||||||
|
# Skip keys that are in the skipped list
|
||||||
|
if is_skipped "$key"; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
if is_skipped "$value"; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
# Check for custom group
|
# Check for custom group
|
||||||
group=$(get_custom_group "$key")
|
group=$(get_custom_group "$key")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user