Command Line Environment

Automatic Shell Environment Loading

Tower automatically loads your shell environment by default. This means most commands and tools available in your terminal should work in Tower, including in hook scripts.

Managing Environment Variables

From version 10.2 onwards, you can define custom environment variables within the Environment tab in Settings:

  1. Open Tower Settings (Tower menu → Settings)
  2. Go to the Environment tab
  3. Add, edit, or remove environment variables as needed

A sample to define your PATH could look like this:

Key: PATH
Value: /usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin

You can add additional key-value pairs as needed. For example, if your hook script needs a specific variable to work properly:

Key: YOUR_VARIABLE
Value: YOUR_VALUE

Working with Dynamic Version Managers

If your hooks use tools managed by version managers like nvm, rbenv, or pyenv and fail with "command not found", this is because Tower can't determine which version should be active for a specific repository. These tools often change the active version based on directory context (e.g., .nvmrc files).

Best Practice: Make your hook scripts self-contained by sourcing the version manager at the start:

#!/bin/sh
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"

# Your hook logic here
pnpm run lint

This ensures hooks work reliably regardless of which app or environment runs them.

Advanced: Using environment.plist

You can also manage environment variables using the environment.plist file located at ~/Library/Application Support/com.fournova.Tower3/environment.plist. This can be useful for:

  • Scripting or automation that needs to set variables programmatically
  • Managing many environment variables at once
  • Advanced configurations

The file is formatted in PLIST XML format. Variables set in environment.plist work alongside variables configured in the Settings UI.

Please note that environment variables like $HOME aren't supported in the environment.plist. Also note that using relative paths might cause problems, which is why you should consider using absolute paths.