Script Types
Termpad supports three types of scripts:Configuring Scripts
1
Open project settings
Click the gear icon next to the project name.
2
Add your scripts
Enter commands for each script type.
Setup Scripts
Setup scripts run automatically when you create a new worktree. Use them for:- Installing dependencies
- Setting up environment files
- Building initial assets
- Starting background services
Scripts run in the default shell/terminal you configured in your settings. Write your commands using the syntax for that shell.
Creating worktrees by default doesn’t include any files in your
.gitignore. If you have .env variables in your main branch and want them brought over to the worktree, add that to your setup script.Examples
- Node.js
- Python
- Rust
- Go
Run Scripts
Run scripts are manually triggered commands for common tasks. You can have multiple run scripts per project.Creating run scripts
1
Open script settings
Navigate to the run scripts section.
2
Add a new script
Click Add Run Script.
3
Configure the script
Enter a name (e.g., “Dev Server”) and the command.
Common run scripts
Running a script
1
Select a worktree
Click on the worktree where you want to run the script.
2
Click Run
Click the Run button in the terminals section/panel at the bottom right.
3
Choose a script
Select which script to run from the dropdown.
Exclusive mode
Some scripts can’t run in multiple worktrees (e.g., dev servers that need a specific port). Enable exclusive mode for these scripts. When you run an exclusive script:- Termpad checks if it’s running elsewhere
- If yes, it stops the other instance
- Then starts the script in your current worktree
Exclusive mode only detects scripts run using the Run Script feature. It won’t detect if you manually run the same command in your terminal.
Cleanup Scripts
Cleanup scripts run when you delete a worktree. When deleting a worktree, Termpad automatically removes the entire worktree directory. Cleanup scripts are useful for doing operations outside the working tree, for example removing build artifacts if applicable.Example
Environment Variables
Scripts have access to Termpad-provided environment variables:Using environment variables
Smart Port Management
Avoid port conflicts when running dev servers across worktrees:1
Configure your scripts
Use
$TERMPAD_PORT in your run scripts:2
Each worktree gets a unique port
Each worktree receives a unique port from a pool of 100 ports available per repository.
Script Tips
Chain commands
Run multiple commands in sequence:Handle failures gracefully
Use|| true to prevent script failure from blocking:
Keep scripts simple
If your script is complex, put it in a file:Test scripts manually first
Before adding a script to Termpad, test it in a terminal to make sure it works.Share scripts with your team
Add atermpad.json file to your repository root to share scripts with teammates. See the Shared Config guide for details.