Shell Hooks
Chau7 reports exit codes after every command and tracks directory changes. Post-command hooks, automatically.
What is Shell Hooks in Chau7?
Shell Hooks is a feature in the Chau7 terminal that reports exit codes after every command and tracks directory changes. Chau7 provides two hook types: post-command hooks (precmd) and directory change hooks (OSC 7). There is no pre-command (preexec) hook.
Chau7 shell hooks fire automatically at key points in the command lifecycle. The shell integration scripts configure them once, and Chau7 runs them on every command without you thinking about them.
How do Chau7's post-command hooks work?
Chau7 integrates shell hooks that fire after every command completes. The post-command hook (precmd) runs after the command finishes and reports the exit code back to Chau7 via a proprietary OSC 9 escape sequence.
The exit code is the information transmitted by the hook. Chau7 uses this to track command success and failure. There is no pre-command (preexec) hook, and command text and execution duration are not sent by the hooks.
What information do Chau7 hooks receive?
Chau7 post-command hooks report the exit code of the last command via a proprietary OSC 9 escape sequence. The shell integration also provides environment variables including CHAU7_SESSION_ID and CHAU7_TAB_ID for identifying the terminal context.
Directory change hooks report the current working directory via OSC 7. This lets Chau7 track which directory each tab is in, enabling features like automatic git status after cd into a repository or context-aware tab titles.
Which shells does Chau7 support for hooks?
Chau7 provides shell integration scripts for Bash, Zsh, and Fish that set up the hook plumbing automatically. The hooks are configured as shell functions or script paths in your shell configuration.
Manual configuration is also possible for other shells by emitting the expected escape sequences that Chau7 listens for.
Can Chau7 trigger actions when you change directories?
Yes. Chau7 directory change hooks fire whenever the working directory changes, whether from an explicit cd command or a directory change triggered by a script.
Chau7's directory change hooks enable workflows like automatically activating Python virtual environments, switching Node.js versions via nvm, or updating the terminal title with project context.
How does Chau7's shell hooks compare to other terminals?
Most terminals rely on manual shell configuration for hooks. iTerm2 offers shell integration but limited hook customization. Alacritty and Kitty have no built-in hook support at all.
Chau7 provides post-command hooks with exit code reporting and directory change hooks out of the box. Chau7's shell hooks work with Bash, Zsh, and Fish, and they integrate directly with the terminal's command lifecycle model.
Why Chau7 shell hooks matter
Shell hooks in Chau7 give the terminal awareness of command outcomes and directory context. Chau7 uses post-command hooks to track exit codes and directory change hooks to follow the working directory, enabling features like AI session tracking and contextual tab titles.
Developers configure Chau7's shell hooks once and they run on every command. No manual intervention. No remembering to trigger a script. Chau7 handles the lifecycle integration automatically.
Questions this answers
- What is Shell Hooks in Chau7 terminal?
- How does Chau7's shell hooks compare to other terminals?
- Terminal post-command hooks automation
- What information do hooks receive?
- Which shells are supported?
Frequently asked questions
What is Shell Hooks in Chau7 terminal?
Shell Hooks is a feature in the Chau7 terminal that reports exit codes after every command and tracks directory changes. Chau7 provides post-command hooks (precmd) and directory change hooks (OSC 7) that fire automatically. There is no pre-command (preexec) hook.
How does Chau7's shell hooks compare to other terminals?
Most terminals rely on manual shell configuration for hooks. iTerm2 offers shell integration but limited hook customization. Alacritty and Kitty have no built-in hook support. Chau7 provides post-command hooks with exit code reporting and directory change hooks out of the box for Bash, Zsh, and Fish.
What information do Chau7 hooks receive?
Chau7 post-command hooks report the exit code of the last command via a proprietary OSC 9 escape sequence. The shell integration also provides environment variables including CHAU7_SESSION_ID and CHAU7_TAB_ID. Directory change hooks report the current working directory via OSC 7. Command text and execution duration are not transmitted by the hooks.
Which shells are supported?
Chau7 provides shell integration scripts for Bash, Zsh, and Fish that set up hook plumbing automatically. Manual configuration is also possible for other shells by emitting the expected escape sequences.
Can Chau7 trigger actions when I change directories?
Yes. Chau7 directory change hooks fire whenever the working directory changes, enabling automatic environment activation, version switching, or context updates.