Skip to content

OscarPastry/trapsh

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

trapsh

Record your shell session and replay it as a clean, shareable bash script.

trapsh acts as a transparent background recorder for your terminal. It hooks into your fish (or bash/zsh or powershell) session, records the commands you run, filters out the noise (like failed commands, typos, and syntax errors), and outputs a clean, ready-to-use bash script.

Perfect for creating tutorials, sharing reproduction steps, or just automating your workflow without having to write the script from scratch.


Demo

readme_better

Features

  • Noise Filtering: Automatically removes failed commands, duplicate entries, and typos from the final output.
  • Cross-Shell Support: Hook installation is supported for fish, bash, zsh, and powershell.
  • Clean Output: Generates a standardized bash script (trapsh_out.sh) that you can immediately run or share.
  • Live Preview: See what your final script will look like before you stop recording.

Installation

From Releases (Pre-built Binaries)

You can download the pre-compiled, standalone binaries from the Releases page for Linux, macOS, and Windows. You do not need Rust installed to run these.

Linux & macOS:

  1. Download the trapsh-linux-amd64 or trapsh-macos-* binary.
  2. Make it executable and move it to your PATH:
    chmod +x trapsh-*
    sudo mv trapsh-* /usr/local/bin/trapsh

Windows:

  1. Download the trapsh-windows-amd64.exe binary.
  2. Rename it to trapsh.exe.
  3. Add the folder containing trapsh.exe to your system's PATH environment variable.

From Source

Ensure you have Rust and Cargo installed, then run:

# Build and install from source
cargo install --path .

# Install the shell hooks (supports fish, bash, zsh, powershell)
trapsh install 

Debugging

if you get the error trapsh: command not found , then run this:

#if your shell is bash
echo 'export PATH="$HOME/.cargo/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc

#if your shell is zsh
echo 'export PATH="$HOME/.cargo/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc

#if your shell is fish
fish_add_path ~/.cargo/bin

#if your shell is powershell
Add-Content $PROFILE "`n`$env:PATH = `"`$env:USERPROFILE\.cargo\bin;`$env:PATH`""

Usage

Using trapsh is simple. Start a session, do your work, and stop it when you're done.

# 1. Begin recording your session
trapsh start

# 2. ... Run your commands normally ...
$ mkdir my_project
$ cd my_project
$ npm init -y

# 3. Check the status of your current session
trapsh status

# 4. Preview the generated script so far
trapsh show           # Filtered, clean preview
trapsh show --raw     # Show everything, including noise and failed commands

# 5. Stop recording and save the output
trapsh stop                   # Saves to ./trapsh_out.sh
trapsh stop -o setup.sh       # Saves to a custom file
trapsh stop --raw             # Save the unfiltered session

How it Works

When you run trapsh start, it initializes a tracker that logs your shell history in real-time. Upon running trapsh stop, it analyzes the return codes of your executed commands, strips out anything that failed (unless --raw is passed), and writes the successful sequence to a file.

Contributing

Contributions, issues, and feature requests are welcome! Feel free to open an issue or pull request.

About

Record your shell session and replay it as a clean bash script.

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors