Skip to content

VictorCano/tabby-post-connect-actions

Repository files navigation

tabby-post-connect-actions

npm version npm downloads

A Tabby plugin that adds per-profile working directory and post-connect script execution for SSH and Local shell connections.

About

Tabby's built-in login scripts handle basic expect/send pairs for automating connection flows. This plugin builds on top of that foundation with a more flexible approach to post-connection setup: a dedicated working directory field that navigates to your project on connect, a multi-line script area for running setup commands in sequence, smart shell prompt detection so commands execute only when the terminal is ready, and configurable navigation methods depending on your workflow.

It does not replace or interfere with existing login scripts — both systems run independently, with this plugin's actions executing after the built-in scripts complete.

Installation

From Tabby's Plugin Manager

  1. Open Tabby Settings
  2. Go to the Plugins tab
  3. Search for tabby-post-connect-actions
  4. Click Install

Manual install

From Tabby's plugin directory:

cd "$(echo ~/Library/Application\ Support/tabby/plugins)" # macOS
# cd "%APPDATA%/tabby/plugins"                             # Windows
# cd ~/.config/tabby/plugins                               # Linux
npm install tabby-post-connect-actions --legacy-peer-deps

Then restart Tabby.

Configuration

Open Tabby Settings and navigate to the Post-Connect Actions tab. From there you can select any profile and configure:

Field Type Default Description
Working Directory string "" Path to navigate to after connecting. Leave empty to skip.
Post-Connect Script string "" Multi-line script to run after navigating. Each non-empty line is sent as a separate command.
CD Method "send" | "command" "send" How to change directory. "send" types cd /path into the terminal. "command" sends cd /path && exec $SHELL to replace the shell in-place (SSH only — falls back to "send" for local shell).
Wait for Prompt boolean true Wait for a shell prompt before running commands.
Prompt Timeout number 5000 Maximum time (ms) to wait for a prompt before proceeding anyway.

Configuration is stored in Tabby's global config under postConnectActions.profiles, keyed by profile ID.

Usage Examples

Navigate to a project directory on connect:

  • Set Working Directory to /home/deploy/my-project

Activate a Python virtualenv after connecting:

  • Set Working Directory to /home/user/my-project
  • Set Post-Connect Script to:
    source venv/bin/activate
    export DJANGO_SETTINGS_MODULE=config.production
    

Source environment and start services on a dev server:

  • Set Working Directory to /opt/app
  • Set Post-Connect Script to:
    source ~/.nvm/nvm.sh
    nvm use 18
    export NODE_ENV=development
    

How It Works

The plugin uses Tabby's TerminalDecorator API to hook into the terminal session lifecycle. When a connection is established:

  1. Prompt detection — If enabled, the plugin watches terminal output for common shell prompt characters ($, #, >, %), stripping ANSI escape codes for reliable matching. If no prompt is detected within the timeout, it proceeds anyway.
  2. Directory change — If a working directory is set, the plugin navigates to it using the configured method.
  3. Script execution — If a post-connect script is set, each non-empty line is sent to the terminal with a short delay between lines.

Actions automatically re-run if the session reconnects.

Compatibility

Connection Type Supported Notes
SSH Yes Full support including cdMethod: "command"
Local shell Yes cdMethod: "command" falls back to "send"
Serial No
Telnet No

Development

# Install dependencies
npm install --legacy-peer-deps

# Build
npm run build

# Watch mode
npm run watch

# Run tests
npm test

# Lint
npm run lint

# Format
npm run format

AI Disclosure

This plugin was developed with the assistance of Claude by Anthropic. All commits in this repository include a Co-authored-by: Claude <noreply@anthropic.com> trailer to reflect this collaboration.

License

MIT

About

Runs commands or sets the working directory automatically after connecting to a session

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors