You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`ENVP` is a shell wrapper command-line tool for macOS and Linux that enables you to run commands or shells with specific environment variable configurations based on profiles. It also allows you to run scripts to set up these profiles. With ENVP, you can easily switch between different environment configurations, even simultaneously in different terminal windows. This tool provides a convenient way to manage and control your environment variables for various development and testing scenarios.
12
12
13
-
ENVP is cli wrapper that sets environment variables by profile based configuration when you execute the command line.
it may works. but I want to simply do `kubectl` (or `k`) 😮💨
54
-
55
-
also, it doesn't scale for other k8s related commands.
56
-
e.g. `k9s`, `skaffold`, `helm`, and so on.
57
-
58
-
- My team has multiple VPN servers for the infrastructures. switching VPN back and forth in the local is annoying. so I run docker container that connects to the VPN server and proxying request by Squid Proxy. it works great on browser with FoxyProxy. but still need to set environment variable in my terminal.
59
-
60
-
- I have multiple servers to run docker remotely
61
-
62
-
```bash
63
-
DOCKER_HOST=ssh://user@workstation-1 docker ps -a
64
-
DOCKER_HOST=ssh://user@workstation-2 docker ps -a
65
-
```
66
-
67
-
and more cases like `VAULT_ADDR`, `ARGO_SERVER`, and so on and so on.
13
+

68
14
69
15
## Installation
70
16
@@ -80,246 +26,43 @@ go install:
80
26
go install github.com/sunggun-yu/envp@<version>
81
27
```
82
28
83
-
## Usage
84
-
85
-
> note: command line must start after double dash `--`.
86
-
87
-
```txt
88
-
ENVP is cli wrapper that sets environment variables by profile when you execute the command line
89
-
90
-
Usage:
91
-
envp profile-name [flags] -- [command line to execute, e.g. kubectl]
92
-
envp [command]
93
-
94
-
Examples:
29
+
## Quick Start
95
30
96
-
# run command with selected environment variable profile.
97
-
# (example is assuming HTTPS_PROXY is set in the profile)
98
-
envp use profile
99
-
envp -- kubectl cluster-info
100
-
envp -- kubectl get pods
101
-
102
-
# specify env var profile to use
103
-
envp profile-name -- kubectl get namespaces
104
-
31
+
### Config file
105
32
106
-
Available Commands:
107
-
add Add environment variable profile
108
-
completion Generate the autocompletion script for the specified shell
109
-
delete Delete environment variable profile
110
-
edit Edit environment variable profile
111
-
help Help about any command
112
-
list List all environment variable profiles
113
-
show Print the environment variables of profile
114
-
start Start new shell session with environment variable profile
115
-
use Set default environment variable profile
116
-
version Print the version of envp
33
+
Location of config file is `~/.config/envp/config.yaml`.
117
34
118
-
Flags:
119
-
-h, --help help for envp
120
-
121
-
Use "envp [command] --help" for more information about a command.
122
-
```
123
-
124
-
### Add profile
125
-
126
-
```bash
127
-
envp add my-proxy \
128
-
-d "profile description" \
129
-
-e HTTPS_PROXY=http://some-proxy:3128 \
130
-
-e "NO_PROXY=127.0.0.1,localhost" \
131
-
-e "DOCKER_HOST=ssh://myuser@some-server"
132
-
```
133
-
134
-
- the value format of environment variable `--env`/`-e` is `NAME=VALUE`. other format will be ignored.
135
-
- you can add multiple environment variables by repeating `--env`/`-e`.
136
-
- added profile will be set to default profile if default is not set.
137
-
138
-
### Set default profile
139
-
140
-
```bash
141
-
envp use <profile-name>
142
-
```
143
-
144
-
### Run command line
145
-
146
-
run command with default profile:
147
-
148
-
```bash
149
-
# set command after double dash --
150
-
envp -- kubectl get pods
151
-
envp -- kubectl exec -it vault-test-app -- sh
152
-
envp -- k9s
153
-
envp -- vault login
154
-
envp -- docker ps -a
155
-
```
156
-
157
-
run command with specific profile:
158
-
159
-
```bash
160
-
# specify the profile to use. --profile / -p
161
-
envp <profile-name> -- kubectl get pods
162
-
envp a-a -- k9s
163
-
envp a-b -- curl -IL https://some-host
164
-
envp g-a -- curl -IL https://some-host
165
-
envp g-b -- kubectx g-b && kubectl get pods
166
-
envp my-lab -- docker ps -a
167
-
envp my-vault-1 -- vault login
168
-
```
169
-
170
-
### Start new shell session with your default `$SHELL`
171
-
172
-
You can create new shell session with injected environment variable from your profile. It might be more useful for most of use case since you can seemlessly execute multiple commands.
173
-
174
-
```bash
175
-
# start new shell session with default profile
176
-
envp start
177
-
178
-
# start new shell session with specific profile
179
-
envp start <profile-name>
180
-
```
181
-
182
-
### List profiles
183
-
184
-
```bash
185
-
envp list
186
-
envp ls
187
-
```
188
-
189
-
result:
190
-
191
-
```txt
192
-
a-profile
193
-
* my-lab-1
194
-
test
195
-
vpn-a
196
-
vpn-b
197
-
```
198
-
199
-
- default profile will be marked with `*`
200
-
201
-
### Show all environment variables of profile
202
-
203
-
print out default profile's env vars:
204
-
205
-
```bash
206
-
envp show
207
-
208
-
ENV_VAR_1=ENV_VAL_1
209
-
ENV_VAR_2=ENV_VAL_2
210
-
ENV_VAR_3=ENV_VAL_3
211
-
```
212
-
213
-
show env vars of specific profile:
214
-
215
-
```bash
216
-
envp show some-profile
217
-
218
-
ENV_VAR_1=ENV_VAL_1
219
-
ENV_VAR_2=ENV_VAL_2
220
-
ENV_VAR_3=ENV_VAL_3
221
-
```
222
-
223
-
show with export option `--export`, `-e`
224
-
225
-
```bash
226
-
envp show --export
227
-
228
-
# you can export env vars of profile with following command
229
-
# eval $(envp show --export)
230
-
# eval $(envp show profile-name --export)
231
-
232
-
export ENV_VAR_1=ENV_VAL_1
233
-
export ENV_VAR_2=ENV_VAL_2
234
-
export ENV_VAR_3=ENV_VAL_3
235
-
```
236
-
237
-
so that, user can export env vars with `eval $(envp show --export)` command
238
-
239
-
```bash
240
-
eval$(envp show --export)
241
-
```
242
-
243
-
>💡 TIP
35
+
> please create folder and config file if it is not created.
244
36
>
245
-
> you can create new shell, `bash/zsh`, session with `envp`
246
-
247
-
```bash
248
-
envp -- zsh
249
-
envp profile-name -- zsh
37
+
> ```bash
38
+
> mkdir -p ~/.config/envp
39
+
> vim ~/.config/envp/config.yaml
40
+
>```
250
41
251
-
# and exit shell session if you want to reset/unset env vars
252
-
exit
253
-
```
42
+
config file example:
254
43
255
-
### Edit profile
256
-
257
-
```bash
258
-
envp edit my-proxy \
259
-
-d "updated profile desc" \
260
-
-e "NO_PROXY=127.0.0.1,localhost"
261
-
```
262
-
263
-
- value will be updated for existing env name
264
-
- removing env from profile will be added later. please update config file directly for now
265
-
266
-
### Delete profile
267
-
268
-
```bash
269
-
envp delete profile
270
-
envp del another-profile
44
+
```yaml
45
+
default: ""
46
+
profiles:
47
+
my-profile:
48
+
desc: profile description
49
+
env:
50
+
- name: HTTPS_PROXY
51
+
value: http://some-proxy:3128
52
+
- name: MY_PASSWORD
53
+
value: $(cat ~/.config/my-password-file)
54
+
init-script:
55
+
- run: |
56
+
echo"this is init script 1"
57
+
- run: |
58
+
echo"this is init script 2"
271
59
```
272
60
273
-
### Nested profile
61
+
### Start new shell with profile
274
62
275
-
nested profile is possible natually thanks to `viper`.
276
-
you can simply divide group and profile by `.` in the profile name.
63
+
You can create new shell session with injected environment variable from your profile.
277
64
278
65
```bash
279
-
envp add group.profile
280
-
envp use group.profile
281
-
envp group.profile -- ls -la
282
-
envp delete group.profile
283
-
envp delete group
284
-
```
285
-
286
-
- if you delete parent profile with delete command, it will also delete all child profiles.
287
-
288
-
## Config file
289
-
290
-
config file will be created at `$HOME/.config/envp/config.yaml` initially. and all profiles and environment variables will be stored in this file.
291
-
292
-
the file format is `YAML` and followed k8s pod env format to avoid map key uncapitalize issue from go/yaml unmarshal.
0 commit comments