-
Notifications
You must be signed in to change notification settings - Fork 0
/
infisical.plugin.zsh
44 lines (35 loc) · 1.38 KB
/
infisical.plugin.zsh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
() {}
function cd {
builtin cd "$@"
if [ -f .infisical.json ]; then
# Verify if infisical binary exists using infisical -v command
if ! infisical -v >/dev/null 2>&1; then
echo "[zsh-infisical] infisical binary not found. Please install it first.\nPlease, install it https://infisical.com/docs/cli/overview" >&2
return 1
fi
DEFAULT_ENV=dev
DEFAULT_URL=https://app.infisical.com/api
# If ZSH_INFISICAL_DEFAULT_ENV variable is set
if [ -n "$ZSH_INFISICAL_DEFAULT_ENV" ]; then
DEFAULT_ENV=$ZSH_INFISICAL_DEFAULT_ENV
fi
# If INFISICAL_API_URL variable is set
if [ -n "$INFISICAL_API_URL" ]; then
DEFAULT_URL=$INFISICAL_API_URL
fi
# If ZSH_INFISICAL_DEFAULT_URL variable is set
if [ -n "$ZSH_INFISICAL_DEFAULT_URL" ]; then
DEFAULT_URL=$ZSH_INFISICAL_DEFAULT_URL
fi
# If ZSH_INFISICAL_VERBOSE variable is set
if [ -n "$ZSH_INFISICAL_VERBOSE" ]; then
VERBOSE=$ZSH_INFISICAL_VERBOSE
fi
if [[ "$VERBOSE" == "1" ]]; then
echo "[INFISICAL] URL: $DEFAULT_URL"
echo "[INFISICAL] ENV: $DEFAULT_ENV"
fi
# Activate the environment using the eval command with the CLI output
eval `infisical --domain=$DEFAULT_URL export -f dotenv-export -e $DEFAULT_ENV`
fi
}