Skip to content

Shell prompt

Show the active checkout in your prompt, the way git prompts show the current branch.

# ~/.bashrc
eval "$(forest prompt init bash)"
# ~/.zshrc
eval "$(forest prompt init zsh)"

Inside a workspace with checkout demo active, the prompt gains a 🌲 demo prefix. Anywhere else it stays the same.

The snippet is plain shell and reads .forest/HEAD directly, so it never starts forest and the prompt stays fast. It walks up from the current directory, stops at the first directory holding .forest or .git, and shows the segment only if that directory has .forest/config.yaml and a valid checkout name in .forest/HEAD. Running the eval line twice is harmless.

To change the icon:

export FOREST_PROMPT_ICON='(f)'

Framework notes

  • With oh-my-zsh, powerlevel10k or another zsh theme, put the eval line after the theme loads. Themes overwrite PROMPT and would drop the segment.
  • If you use an array PROMPT_COMMAND (bash 5.1+), the snippet's string prepend keeps only the first element. Register _forest_prompt_update yourself instead.
  • If bash shows a literal ${FOREST_PROMPT}, promptvars is off. Run shopt -s promptvars.