Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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 develop profile 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 PATH to FLK_ORIG_PATH (the PATH before activation) first, so removed packages are gone. Manual PATH changes 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_REF and FLK_PROFILE to the new profile reference
  • Reloads via direnv or nix develop as 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.