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 commands for hot-reloading and profile switching within an active development environment. These are provided by the flk hook and are not standalone flk subcommands.

Setup

Add the shell hook to your profile:

# Bash
eval "$(flk hook bash)"

# Zsh
eval "$(flk hook zsh)"

# Fish
flk hook fish | source

refresh

Reload the current environment to pick up configuration changes.

# Make changes
flk add ripgrep
flk env add MY_VAR "hello"

# Apply without leaving the shell
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 the pre-activation snapshot (FLK_ORIG_PATH) before re-entering, so removed packages actually disappear instead of lingering via the inherited PATH (this also discards manual PATH edits made inside the shell)

switch <profile>

Switch to a different profile and reload the environment.

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

refresh and switch are environment-aware. In a shell started by flk global activate, FLK_ENV_DIR points at the global config directory, and both commands resolve flake refs and profile caches against it — regardless of your current working directory. In project shells (FLK_ENV_DIR unset) they operate on the current directory as before. Direnv integration is skipped for global shells.

You can also cross environments explicitly — the new shell always supersedes the current one (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 Integration

When direnv is available and .envrc exists, both refresh and switch use direnv reload for a seamless experience. Without direnv, they use exec nix develop, which replaces the current shell process.

Notes

  • Supported shells: bash, zsh, fish
  • Requires the flk shell hook to be sourced in your shell profile
  • See also: flk hook, flk activate