This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
tramp-term.el is an Emacs Lisp package that provides automatic setup of directory tracking in SSH sessions. It creates ansi-term buffers with SSH connections that automatically configure TRAMP integration for seamless remote file editing.
Core Components:
tramp-term.el- Single-file package containing all functionality- Main entry point:
tramp-terminteractive function - SSH connection handling with automatic prompt detection and response
- Multi-shell support with auto-detection and per-host configuration
Key Functions:
tramp-term: Main interactive command to establish SSH connectiontramp-term--do-ssh-login: Handles SSH authentication flowtramp-term--initialize: Dispatches to shell-specific initialization functionstramp-term--detect-shell: Auto-detects remote shell using$0variabletramp-term--select-host: Provides host completion from ~/.ssh/config
Shell Architecture:
- Shell-specific initialization functions:
tramp-term--initialize-bash,tramp-term--initialize-zsh,tramp-term--initialize-tcsh - Per-shell AnSiT escape sequence injection for directory tracking
- Host-specific shell caching via
tramp-term-host-shellscustomization variable
Dependencies:
- Built-in Emacs packages:
termandtramp - Supports bash, zsh, and tcsh shells on remote hosts
- Uses ~/.ssh/config for host completion
Testing:
# Start test containers with different shells
docker compose up -d
# Run shell compatibility tests
./scripts/test-runner.sh
# Manual testing in Emacs
M-x tramp-term RET tramp-zsh RETPackage Distribution:
- Only
tramp-term.elis distributed via MELPA/ELPA - Test infrastructure and documentation remain in repository only
Supported Shells:
- Bash: Uses PROMPT_COMMAND for directory tracking
- Zsh: Uses precmd_functions array
- Tcsh: Uses aliases for cd/pushd/popd with
/bin/echo -efor escape sequences
Auto-Detection Logic:
tramp-term--detect-shellusesecho "$MARKER$0"to identify shell- Results cached in
tramp-term-host-shellsper hostname - Falls back to user prompt if detection fails
Configuration System:
tramp-term-default-shell: Global default ('bash, 'zsh, 'tcsh, or 'auto)tramp-term-host-shells: Alist of (hostname . shell-type) pairs- Automatic persistence via
customize-save-variable
Docker Test Environment:
- Separate containers for bash, zsh, tcsh shells
- SSH key-based authentication via generated test keys
- Clean shell environments for testing auto-detection
- Port mapping: zsh(2222), tcsh(2223), bash(2225)
Test Verification Points:
- Shell auto-detection accuracy
- AnSiT escape sequence injection
- Directory tracking functionality
- TRAMP integration with
default-directoryupdates