flk switch / refresh
Shell functions defined by the shell hook, not flk subcommands. They only work inside an activated environment.
refresh
Reloads the current environment after a config change.
flk add ripgrep
refresh
Behavior
- With direnv: runs
direnv reload - Without direnv: reuses a saved
nix developprofile when it is current - Without direnv: refreshes that saved profile when the environment definition changes
- Reads the active profile from
FLK_FLAKE_REF(fallback:FLK_PROFILE) - Resets
PATHtoFLK_ORIG_PATH(thePATHbefore activation) first, so removed packages are gone. ManualPATHchanges made in the shell are lost too.
switch <profile>
Moves to another profile.
switch backend
switch frontend
Behavior
- Validates the profile name (alphanumeric,
-,_only) - Sets
FLK_FLAKE_REFandFLK_PROFILEto the new profile reference - Reloads via direnv or
nix developas appropriate, reusing the saved profile cache when possible
Global environments
In a shell started by flk global activate, FLK_ENV_DIR points at the global directory and both functions work on it, whatever the current directory. In project shells (FLK_ENV_DIR unset) they work on the current directory. direnv is not used for global shells.
To move between environments explicitly (the new shell replaces the current one with exec; shells never stack):
refresh -g # jump to (or reload) the global env, default profile
switch -g cli-tools # jump to a specific global profile
switch -l backend # back to the cwd project's 'backend' profile
-g/--global resolves the target via flk global ref / flk global path; -l/--local returns to the current directory’s project.
direnv
With direnv installed and an .envrc present, both functions run direnv reload. Otherwise they exec nix develop, replacing the current shell.