Skip to content

Shell Integration

The shell hook is optional. Without it, aisw use still writes live tool credential files and updates ~/.aisw/config.json. The hook adds one capability: applying the emitted environment variable exports (CLAUDE_CONFIG_DIR, CODEX_HOME) into the current shell session.

Add to ~/.zshrc:

Terminal window
eval "$(aisw shell-hook zsh)"

Then reload:

Terminal window
source ~/.zshrc

Add to ~/.bashrc (interactive shells) or ~/.bash_profile:

Terminal window
eval "$(aisw shell-hook bash)"

Then reload:

Terminal window
source ~/.bashrc

Add to ~/.config/fish/config.fish:

Terminal window
aisw shell-hook fish | source

Or as a standalone file:

Terminal window
aisw shell-hook fish > ~/.config/fish/conf.d/aisw.fish
Terminal window
echo "$AISW_SHELL_HOOK"
# Expected: 1

The hook wraps the aisw function in your shell. When you run aisw use ..., the hook:

  1. Runs aisw use ... --emit-env to write the credential files and print export VAR=value lines to stdout.
  2. Evals those exports in the current shell, so CLAUDE_CONFIG_DIR and CODEX_HOME are set immediately.
  3. Passes all other aisw subcommands through to the binary unchanged.

Without the hook, you can achieve the same effect manually:

Terminal window
eval "$(aisw use claude work --emit-env)"

Remove the eval line from your shell config and open a new shell.

To remove hook blocks that aisw init or aisw shell-hook added:

Terminal window
aisw uninstall --dry-run # preview
aisw uninstall --yes # apply

aisw ships completion scripts for bash, zsh, and fish. They are installed automatically by the Homebrew formula and shell installer.

ShellPath
bash~/.local/share/bash-completion/completions/aisw
zshWritable fpath entry, or ~/.zsh/completions/_aisw
fish~/.config/fish/completions/aisw.fish
Terminal window
cargo build --release
install -Dm644 completions/aisw.bash \
~/.local/share/bash-completion/completions/aisw
install -Dm644 completions/_aisw \
~/.zsh/completions/_aisw
install -Dm644 completions/aisw.fish \
~/.config/fish/completions/aisw.fish

For zsh, ensure the completion directory is in your fpath:

Terminal window
fpath=(~/.zsh/completions $fpath)
autoload -U compinit && compinit