flk hook
Generate shell hooks that enable the refresh and switch commands for hot-reloading your development environment.
flk hook bash
flk hook zsh
flk hook fish
Usage
Add the hook output to your shell profile to enable refresh and switch:
# Bash (~/.bashrc)
eval "$(flk hook bash)"
# Zsh (~/.zshrc)
eval "$(flk hook zsh)"
# Fish (~/.config/fish/config.fish)
flk hook fish | source
Supported Shells
bashzshfish
Commands Provided by the Hook
Once sourced, two shell functions become available:
refresh
Reload the current development environment. Picks up changes you’ve made (added packages, env vars, commands) without leaving the shell.
# After adding a package
flk add ripgrep
refresh
- If direnv is present and
.envrcexists, runsdirenv reload - Otherwise, reuses a cached
nix developprofile when it is still fresh - Rebuilds that cached profile when the flake inputs or relevant
.flkfiles change - Uses
FLK_FLAKE_REF(fallback:FLK_PROFILE) to determine the active profile
switch <profile>
Switch to a different profile and reload the environment.
switch backend
switch frontend
- Validates the profile name before switching
- Updates
FLK_FLAKE_REFandFLK_PROFILE, then reloads via direnv ornix develop - Reuses the saved profile cache until the environment definition changes
Notes
- The hook integrates with direnv automatically — if
.envrcis present, it usesdirenv reloadinstead ofexec nix develop - Profile names must be alphanumeric (with
-or_) - See also: flk activate, flk direnv