-
Couldn't load subscription status.
- Fork 3
3. Basic Usage
To use envfetch, run envfetch <COMMAND> <ARGS> in your terminal.
You can run envfetch help to see help message or envfetch --version to see program's version.
Note
Interactive mode is currently WIP and only list variables is available. See for progress in https://github.com/ankddev/envfetch/issues/17.
Run interactive mode with TUI.
Usage:
envfetch interactive
This will start TUI, where you will be able to work with environment variables.
Initialize config file for envfetch.
Usage:
envfetch init-config
Options:
-
--help/-h- showw help message.
Warning
Currently this command will overwrite any existing config file!
Set environment variable and optionally run process.
Usage:
envfetch set <KEY> <VALUE> [-- <PROCESS>], where:
-
KEY- name of environment variable -
VALUE- value of environment variable -
PROCESS- name of process which you want to run (optional if --global is used)
Options:
-
--help/-h- show help message -
--global/-g- set variable permanently in system environment- On Windows: stores in registry
- On Unix: stores in shell config (.bashrc, .zshrc, or config.fish)
For example:
$ envfetch set MY_VAR "Hello" -- "npm run" # temporary for process
$ envfetch set MY_VAR "Hello" --global # permanent system-wideAdd value to the end of environment variable and optionally run the process
Usage:
envfetch add <KEY> <VALUE> [-- <PROCESS>], where:
-
KEY- name of environment variable -
VALUE- value of environment variable to add -
PROCESS- name of process which you want to run (optional if --global is used)
Options:
-
--help/-h- show help message -
--global/-g- update variable permanently in system environment- On Windows: stores in registry
- On Unix: stores in shell config (.bashrc, .zshrc, or config.fish)
For example:
$ envfetch add PATH "../hello.exe" -- "cargo run" # temporary for process
$ envfetch add MY_VAR "Hello" --global # permanent system-widePrint all environment variables
Usage:
envfetch print
Options:
-
--help/-h- show help message -
--format <FORMAT>/-f <FORMAT>- set custom format.
By default, it uses format {name} - "{value}". In format string {name} is replaced with name of the variable and {value} is replaced with it's value.
For example:
$ envfetch print
SHELL = "powershell"
windir = "C:\\Windows"
SystemDrive = "C:"
SystemRoot = "C:\\Windows"
...$ envfetch print --format "{name}: {value};"
SHELL: powershell;
windir: C:\\Windows;
SystemDrive: C:;
SystemRoot: C:\\Windows;
...It will print all environment variables in given format.
Get value of environment variable
Usage:
envfetch get <KEY>, where:
-
KEY- name of environment variable
Options:
-
--help/-h- show help message -
--no-similar-names/-s- disable showing similar variables if variable not
For example:
$ envfetch get MY_VAR
"Hello"It will print value of specified variable.
Delete variable and optionally start process.
Usage:
envfetch delete <KEY> [-- <PROCESS>], where:
-
KEY- name of environment variable -
PROCESS- name of command to run (optional if --global is used)
Options:
-
--help/-h- show help message -
--global/-g- delete variable permanently from system environment
For example:
$ envfetch delete MY_VAR -- "npm run" # temporary for process
$ envfetch delete MY_VAR --global # permanent system-wideLoad environment variables from dotenv-style file and optionally run process.
Usage:
envfetch load [PROCESS], where:
-
PROCESS- name of process which you want to run (optional if --global is used)
Options:
-
--help/-h- show help message -
--file <FILE>/-f <FILE>- relative or absolute path to file to read variables from. Note that it must be in .env format. By default, program loads variables from.envfile in current directory. -
--global/-g- load variables permanently into system environment
For example:
$ envfetch load -- "npm run" # temporary for process
$ envfetch load --global # permanent system-wide
$ envfetch load --global --file .env.prod # permanent from specific fileNote
When using --global flag:
- On Windows, variables are stored in the registry under HKEY_CURRENT_USER\Environment
- On Unix-like systems, variables are stored in shell configuration files (.bashrc, .zshrc, or config.fish)
Without --global flag, variables are only set for the current process run